api-platform / api-platform/create-client

Dynamic entrypoint

Offen
#248 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
376
Forks
132
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**Description**
There should be an option to have a dynamic entrypoint when generating client code.

Currently the API endpoint passed to the generator is also used as entrypoint. This is not optimal:

1. A development setup may be accessed differently via CLI and via web (e.g. using internal service host names and public URLs in a Docker Compose setup)
2. Different environments need different host names, hardcoding one will break requests.

**Example**
Running the generator with `http://apache/api/` will generate all code and lead to exactly this being set in `config/entrypoint.js`. Now accessing `http://app.local/` will fail since `apache` is a host name internally resolved in a Docker Compose setup while the setup is accessed via `app.local` from the host machine.

Currently we work around this by adjusting `entrypoint.js` like this after generating the code:

```js
export const ENTRYPOINT = `${location.protocol}//${location.host}/api/`;
```

Maybe this or similar could be integrated for dynamic entrypoints.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.