New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic base url using env vars #90
Comments
Modifying the OpenAPI config sounds precisely like what you need. Changing the Import the constant into your runtime and modify it before setting up the react app. /** main.tsx */
import { OpenAPI as OpenAPIConfig } from './openapi/requests/core/OpenAPI';
...
OpenAPIConfig.BASE = 'www.domain.com/api';
...
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
</React.StrictMode>
); |
Oh! I didn't know I was able to override it like that. I'll try it out! |
It does work as expected! I guess it is just a matter to document it in a FAQ. Thank you so much for the help! |
Opened PR #88 to add info in readme. |
Is your feature request related to a problem? Please describe.
Currently, I'm unable to use a dynamic base for the URLs. In production webs, urls might differ from those in dev environments. I saw that we have a
--base
option, but it seems that only a string can be sent.Describe the solution you'd like
Make --base more flexible so it can also accept env vars. This is currently possible if we modify the OpenAPI config
Describe alternatives you've considered
I also considered using the new interceptor feature, but it isn't possible to modify the URL.
Additional context
This feature would be really good in order to be able to prefetch queries in server components as fetch calls doesn't accept relative paths.
The text was updated successfully, but these errors were encountered: