fix: resolve internal docker hostnames to client window location hostname in browser context
All checks were successful
Staging Build / build (push) Successful in 1m49s
All checks were successful
Staging Build / build (push) Successful in 1m49s
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user