api-platform / api-platform/create-client

Dynamic entrypoint

未關閉
#248 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
376
分支
132
PR 合併指標
30 天內沒有已合併 PR

描述

**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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。