vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
895 stars 56 forks source link

Make the client prefix configurable #148

Open haijian-vaadin opened 2 years ago

haijian-vaadin commented 2 years ago

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.

Artur- commented 2 years ago

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

haijian-vaadin commented 2 years ago

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

TatuLund commented 1 year ago

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

TatuLund commented 1 year ago

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 commented 6 months ago

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 commented 6 months ago

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