feat(config): resolve the API base at runtime from config.js
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Runtime configuration — edited on the server, not baked into the bundle.
|
||||
*
|
||||
* Vite inlines import.meta.env.VITE_* at build time, so a bundle built for one
|
||||
* backend URL cannot be pointed at another without rebuilding. That is the wrong
|
||||
* shape for a deployment where the backend goes up first and the UI follows, or
|
||||
* where the same artifact is promoted from demo to staging. This file is served
|
||||
* from the static root unbundled, so ops can change the API base and reload.
|
||||
*
|
||||
* Precedence, highest first:
|
||||
* 1. apiBaseUrl below, if it is a non-empty string
|
||||
* 2. VITE_UDYAM_API_BASE_URL, compiled in at build time
|
||||
* 3. "/api/v1/udyam" — same-origin, which is what the nginx and httpd configs
|
||||
* in DEPLOYMENT.md set up
|
||||
*
|
||||
* Leave it empty for a same-origin deployment; that is the common case and needs
|
||||
* no edit. Set it when the API lives on another host:
|
||||
*
|
||||
* apiBaseUrl: "https://udyamlinc-api.lincpay.tech/api/v1/udyam"
|
||||
*
|
||||
* A cross-origin value also needs that origin in the backend's
|
||||
* UDYAM_CORS_ALLOWED_ORIGINS, or the browser blocks every call while the API
|
||||
* itself looks healthy.
|
||||
*
|
||||
* This file must never be cached — the server configs send no-store for it.
|
||||
* Cached, it silently pins the old URL for anyone who has already loaded the app.
|
||||
*/
|
||||
window.__UDYAM_CONFIG__ = {
|
||||
apiBaseUrl: '',
|
||||
}
|
||||
Reference in New Issue
Block a user