fix teacher, parent and admin pages

This commit is contained in:
root
2026-04-25 00:00:10 -04:00
parent 7fe34dde0d
commit 3e77fc92c7
275 changed files with 46412 additions and 3325 deletions
+19 -3
View File
@@ -1,12 +1,28 @@
/** Prefix for Laravel API when the SPA is served from another origin (production). Empty in dev with Vite proxy. */
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://192.168.3.100:8000`).
* Override proxy target with **`VITE_PROXY_API`**. **`VITE_API_ORIGIN` is not used in dev** (avoids cross-origin from the browser).
*
* **Production build:** `VITE_API_ORIGIN` if set, else `PROD_API_ORIGIN`.
*/
export function apiOrigin(): string {
if (import.meta.env.DEV) {
return ''
}
const v = import.meta.env.VITE_API_ORIGIN
const fallback = 'https://api.alrahmaisgl.org'
return typeof v === 'string' && v.trim() ? v.replace(/\/$/, '') : fallback
if (typeof v === 'string' && v.trim()) {
return v.replace(/\/$/, '')
}
return PROD_API_ORIGIN
}
export function apiUrl(path: string): string {
const base = apiOrigin()
const p = path.startsWith('/') ? path : `/${path}`
if (!base) return p
return `${base}${p}`
}