Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the client prefix configurable #148

Open
haijian-vaadin opened this issue Dec 9, 2021 · 6 comments
Open

Make the client prefix configurable #148

haijian-vaadin opened this issue Dec 9, 2021 · 6 comments
Labels
enhancement New feature or request hilla Issues related to Hilla

Comments

@haijian-vaadin
Copy link
Contributor

In the new generator, it's always using connect as the prefix. However, in the old generator, the connect prefix is configurable, i.e. user can configure it in the application.properties file.

@haijian-vaadin haijian-vaadin added enhancement New feature or request hilla Issues related to Hilla labels Dec 9, 2021
@Artur-
Copy link
Member

Artur- commented Dec 9, 2021

Do we really need this? We have been using /VAADIN now for 20 years and nobody has ever needed to configure it

@haijian-vaadin
Copy link
Contributor Author

Maybe not, that's why I am creating this issue as an enhancement ticket, not blocking the current PR.

@TatuLund
Copy link
Contributor

There is an issue as this feature has been already documented https://hilla.dev/docs/lit/guides/endpoints/#configuring-endpoint-urls

@TatuLund
Copy link
Contributor

TatuLund commented Aug 8, 2023

As a temporary workaround you can copy the frontend/generated/connect-client.default.ts file to frontend/connect-client.ts and change the value of the prefix value in the object provided to the ConnectClient

import { ConnectClient as ConnectClient_1 } from "@hilla/frontend";
const client_1 = new ConnectClient_1({ prefix: "abcd" });
export default client_1;

@Feuerwerk
Copy link

I'm upgrading a legacy application to the newest version of Hilla (at time of writing this it is version 2.5.6) so I'm not entirely free with the selection of paths within my webroot.
In this application the frontend stuff is below /app and the hilla endpoints are below /connect.
With hilla 1.3.2 this was never a problem, the generated default ConnectClient had the correct prefix "../connect". But now with the hardcoded "connect" prefix all endpoint calls have the incorrect url http://server/app/connect/MyEndpoint/function

As a workaround I modified index.ts imported the default ConnectClient from connect-client.default.ts and change the prefix but it would be nice to have it working without that or at least documented how to change that prefix.

@TatuLund I don't understand how your workaround is working. How is frontend/connect-client.ts getting used because the generated endpoints refer to generated/connect-client.default.ts ?

@mcollovati
Copy link
Contributor

The connect-client.default.ts is generated and used only if a custom connect-client.ts does not exists
https://github.com/vaadin/hilla/blob/main/packages/ts/generator-plugin-client/src/index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hilla Issues related to Hilla
Projects
None yet
Development

No branches or pull requests

5 participants