Setting base path dynamically for production builds.
See original GitHub issueYou usually develop against your server running at some local address, and use some other base path in production, e.g:
http://locahost:8080
locally and https://myprodserver
in production.
I would like the possibility to change the base path dynamically for creating my production builds.
If I understand correctly this comes directly from the OpenApi-spec-file, as of now, but I would like this to be independent of the OpenApi-spec, maybe as an input param to the cli-tool, or as an override through an environment-variable.
If there already is a way of doing this, without the need to change my OpenApi-spec generated at the backend, I would love to know.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Angular 2+ - Set base href dynamically - Stack Overflow
If you are using Angular CLI 6, you can use the deployUrl/baseHref options in angular.json (projects > xxx > architect > build >...
Read more >Angular: Set Base URL Dynamically - Project Codify
If we want to change the base URL, we have two problems to solve: 1. Handle Angular routing to accommodate base URL. 2....
Read more >Building for Production - Vite
If you are deploying your project under a nested public path, simply specify the base config option and all asset paths will be...
Read more >Base Path - next.config.js
Base Path added. To deploy a Next.js application under a sub-path of a domain you can use the basePath config option. ... Note:...
Read more >Dynamic Multiple Base URL with Annotations | Android
Now we need a flag to manipulate base urls for each retrofit call. We can define an annotation class and set it to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@knobel-dk I have use something like this in the past:
setupOpenAPI.ts
(imported as one of the first files)Then during a production build the ‘regular’ base is used that was there in the OpenAPI spec.
This works with the Webpack environment plugin: https://webpack.js.org/plugins/environment-plugin/ you need to setup this for your repo. Similar plugins exists for Rollup and others.
Hi @staklau you can always change the base path bt setting this in OpenAPI.BASE = ‘http://mydomain.com/api’. You can do that based on the environment config or inject it via webpack, whatever works.