hilla icon indicating copy to clipboard operation
hilla copied to clipboard

Make the client prefix configurable

Open haijian-vaadin opened this issue 3 years ago • 6 comments

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 avatar Dec 09 '21 09:12 haijian-vaadin

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

Artur- avatar Dec 09 '21 09:12 Artur-

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

haijian-vaadin avatar Dec 09 '21 09:12 haijian-vaadin

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

TatuLund avatar Jun 28 '23 16:06 TatuLund

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;

TatuLund avatar Aug 08 '23 10:08 TatuLund

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 ?

Feuerwerk avatar Feb 27 '24 11:02 Feuerwerk

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

mcollovati avatar Feb 27 '24 12:02 mcollovati