This commit is contained in:
2026-08-27 17:48:20 +05:30
parent 0a3e6302b9
commit bf4dc4e888
2 changed files with 37 additions and 6 deletions

View File

@@ -20,14 +20,31 @@ import type { FiestaEnvelope } from './types';
* this, production means that" is invisible from the outside, and someone
* reading `.env` to find the backend would have found nothing.
*
* The `'/fiesta'` fallback is for a build with no `.env` at all. It routes
* through the dev proxy (`vite.config.ts`) or nginx (`nginx.conf.template`),
* both of which forward to the same host — so a missing variable degrades to a
* working same-origin path rather than to a broken one.
* The fallback is the REAL HOST, not the same-origin `/fiesta` prefix it used
* to be. That prefix looked like a safe degradation and was not: a platform
* that writes its own `.env` into the build context (Dokploy does) erases the
* committed `VITE_API_BASE`, and the bundle then aims every call at whatever
* domain serves the console — `https://app.nearledaily.com/fiesta/live/api/...`
* instead of Fiesta. It kept working only because nginx happens to proxy that
* prefix, which is what made the misconfiguration invisible.
*
* Override per machine with `.env.local`, which is gitignored.
* Defaulting to the host means a missing variable can no longer silently
* re-point the backend at the console's own domain. `Dockerfile` also passes
* `VITE_API_BASE` as a build argument, so the value survives an overwritten
* `.env`.
*
* A trailing slash is stripped: every path below starts with `/`, and
* `https://host//live/api/...` is a different URL to the upstream router.
*
* Override per machine with `.env.local`, which is gitignored — set it to
* `/fiesta` to route through the dev proxy or nginx instead.
*/
export const API_BASE = import.meta.env['VITE_API_BASE'] ?? '/fiesta';
const configuredBase = (import.meta.env['VITE_API_BASE'] ?? '').trim();
export const API_BASE = (configuredBase || 'https://fiesta.nearle.app').replace(
/\/+$/,
'',
);
/** Every console route lives under this prefix. */
export const WEB = '/live/api/v1/web';