mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-07-30 00:55:34 +00:00
26 lines
788 B
TypeScript
26 lines
788 B
TypeScript
![]() |
export const getApiBaseUrl = (): string => {
|
||
|
const envUrl = import.meta.env.VITE_API_BASE_URL;
|
||
|
|
||
|
// In development, use empty string to leverage Vite proxy
|
||
|
// In production/Tauri, use localhost:8080 directly
|
||
|
// if (envUrl !== undefined) {
|
||
|
// console.log(`Using API base URL from environment: ${envUrl}`);
|
||
|
// return envUrl;
|
||
|
// }
|
||
|
|
||
|
// Fallback for development
|
||
|
console.log('Using default API base URL: http://localhost:8080');
|
||
|
return 'http://localhost:8080';
|
||
|
};
|
||
|
|
||
|
export const makeApiUrl = (endpoint: string): string => {
|
||
|
const baseUrl = getApiBaseUrl();
|
||
|
|
||
|
// If baseUrl is empty (development), return endpoint as-is for proxy
|
||
|
if (!baseUrl) {
|
||
|
return endpoint;
|
||
|
}
|
||
|
|
||
|
// For production, combine base URL with endpoint
|
||
|
return `${baseUrl}${endpoint}`;
|
||
|
};
|