chore: seminarhof customer project

This commit is contained in:
e2e
2026-07-11 08:03:49 +02:00
commit 75a531bf0c
188 changed files with 20779 additions and 0 deletions

24
apps/app/src/lib/env.ts Normal file
View File

@@ -0,0 +1,24 @@
// Endpoints come from env, never hardcoded.
//
// In local dev VITE_API_URL is set at build time and Vite replaces the
// import.meta.env reference inline. In deployed/sandbox bundles VITE_API_URL is
// a runtime Worker binding — invisible to Vite at build time — so it's undefined
// in the bundle. We fall back to the current origin + /api, which is correct
// because the dispatcher routes every /api/* path to the API on the same host.
export function apiUrl(): string {
if (typeof window !== 'undefined' && (window as any).__E2E_API_URL) {
// E2E talks directly to the backend (no vite proxy). Better Auth is mounted
// at /api/auth there, while pikku routes live at the root — so the auth
// client must add the /api prefix that __E2E_API_URL (bare host) lacks.
return `${(window as any).__E2E_API_URL as string}/api`
}
if (import.meta.env.SSR) {
// SSR context: the auth client is only consumed in the browser. Return the
// build-time var when available or a placeholder so SSR never throws.
return import.meta.env.VITE_API_URL ?? '/__api'
}
// Client: build-time var (local dev) or derive from the current origin.
// Better Auth's client requires an absolute base URL, so never return a bare
// relative '/api' here — '/api/auth' throws "Invalid base URL".
return import.meta.env.VITE_API_URL ?? `${window.location.origin}/api`
}