Files
Stirling-PDF/frontend/src/core/services/apiClientConfig.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
768 B
TypeScript
Raw Normal View History

2025-11-05 11:44:59 +00:00
/**
* Get the base URL for API requests.
2025-11-26 17:21:42 +00:00
*
* Priority:
* 1. window.STIRLING_PDF_API_BASE_URL (runtime override - fixes hardcoded localhost issues)
* 2. import.meta.env.VITE_API_BASE_URL (build-time env var)
* 3. '/' (relative path - works for same-origin deployments)
*
* Note: Runtime override is needed because VITE_API_BASE_URL gets baked into the build.
* If someone builds with VITE_API_BASE_URL=http://localhost:8080, it breaks production deployments.
2025-11-05 11:44:59 +00:00
*/
export function getApiBaseUrl(): string {
2025-11-26 17:21:42 +00:00
// Runtime override to fix hardcoded localhost in builds
if (typeof window !== 'undefined' && (window as any).STIRLING_PDF_API_BASE_URL) {
return (window as any).STIRLING_PDF_API_BASE_URL;
}
2025-11-05 11:44:59 +00:00
return import.meta.env.VITE_API_BASE_URL || '/';
}