hilla
hilla copied to clipboard
Make the client prefix configurable
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.
Do we really need this? We have been using /VAADIN now for 20 years and nobody has ever needed to configure it
Maybe not, that's why I am creating this issue as an enhancement ticket, not blocking the current PR.
There is an issue as this feature has been already documented https://hilla.dev/docs/lit/guides/endpoints/#configuring-endpoint-urls
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;
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
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 ?
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