hot fix #5 dev day #70

This commit is contained in:
Tomas Dvorak
2025-10-24 23:21:57 +02:00
parent b8839fc1ff
commit 81389c108f
13 changed files with 45 additions and 37 deletions
+9 -5
View File
@@ -31,11 +31,15 @@ const resolveBackendUrl = (path: string) => {
if (/^https?:\/\//i.test(path)) return path;
if (path.startsWith('/cache') || path.startsWith('/uploads') || path.startsWith('/api/')) {
const explicit = process.env.REACT_APP_API_BASE_URL || process.env.REACT_APP_API_URL || '';
const origin = explicit
? new URL(explicit, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin
: (typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000');
// Use URL constructor so query strings in `path` (e.g. /api/v1/x?t=123) are handled correctly
return new URL(path, origin).toString();
if (typeof window === 'undefined') {
// In non-browser contexts, avoid forcing any origin; return the relative path
return path;
}
const baseOrigin = explicit
? new URL(explicit, window.location.origin).origin
: window.location.origin;
// Use URL constructor so query strings in `path` are handled correctly
return new URL(path, baseOrigin).toString();
}
return path;
} catch {