fix: resolve internal docker hostnames to client window location hostname in browser context
All checks were successful
Staging Build / build (push) Successful in 1m49s

This commit is contained in:
DanielS
2026-06-23 02:42:50 +02:00
parent ca69db2395
commit c0c5240f8d
4 changed files with 24 additions and 4 deletions

View File

@@ -11,3 +11,21 @@ export const hasEnvVars =
(process.env.SUPABASE_ANON_KEY ||
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY ||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY);
export function resolveSupabaseUrl(url: string | undefined): string | undefined {
if (!url) return url;
if (typeof window !== 'undefined') {
try {
const parsed = new URL(url);
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
parsed.hostname = window.location.hostname;
return parsed.toString().replace(/\/$/, '');
}
} catch {
return url
.replace('//supabase-kong', `//${window.location.hostname}`)
.replace('//kong', `//${window.location.hostname}`);
}
}
return url;
}