update the new school year model
This commit is contained in:
+10
-7
@@ -3,20 +3,23 @@ const PROD_API_ORIGIN = 'https://api.alrahmaisgl.org'
|
||||
/**
|
||||
* Laravel API base URL.
|
||||
*
|
||||
* **Vite dev:** same-origin `/api/...`; `vite.config.ts` proxies to the API (default `http://localhost:8080`).
|
||||
* Override proxy target with **`VITE_PROXY_API`**. **`VITE_API_ORIGIN` is not used in dev** (avoids cross-origin from the browser).
|
||||
* Dev defaults to same-origin `/api/...` so Vite can proxy requests to Laravel.
|
||||
* Set `VITE_API_ORIGIN` when you want the browser to call Laravel directly, e.g.
|
||||
* `VITE_API_ORIGIN=http://localhost:8000 npm run dev`.
|
||||
*
|
||||
* **Production build:** `VITE_API_ORIGIN` if set, else `PROD_API_ORIGIN`.
|
||||
* If `VITE_API_ORIGIN` is not set in dev, `vite.config.ts` proxies `/api` to
|
||||
* `VITE_PROXY_API` or `http://localhost:8000` by default.
|
||||
*/
|
||||
export function apiOrigin(): string {
|
||||
if (import.meta.env.DEV) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const v = import.meta.env.VITE_API_ORIGIN
|
||||
if (typeof v === 'string' && v.trim()) {
|
||||
return v.replace(/\/$/, '')
|
||||
}
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return PROD_API_ORIGIN
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user