fix: resolve Supabase storage pdf URLs on client and server
Some checks failed
Staging Build / build (push) Has been cancelled

This commit is contained in:
DanielS
2026-07-03 00:49:11 +02:00
parent 78a16607f9
commit 4b3ba63e2c
4 changed files with 24 additions and 5 deletions

View File

@@ -40,6 +40,22 @@ export function resolveSupabaseUrl(url: string | undefined): string | undefined
}
return resolved;
}
} else {
// Server-Side fallback to localhost:8000 (for local development)
try {
const parsed = new URL(url);
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
parsed.hostname = 'localhost';
parsed.port = '8000';
return parsed.toString().replace(/\/$/, '');
}
} catch {
return url
.replace('//supabase-kong:8000', '//localhost:8000')
.replace('//kong:8000', '//localhost:8000')
.replace('//supabase-kong', '//localhost:8000')
.replace('//kong', '//localhost:8000');
}
}
return url;
}