fix: prevent resolving internal supabase urls to localhost inside docker container
All checks were successful
Staging Build / build (push) Successful in 3m37s

This commit is contained in:
DanielS
2026-07-03 01:04:49 +02:00
parent 728363fa71
commit e67695e36e
2 changed files with 15 additions and 12 deletions

View File

@@ -43,6 +43,7 @@ ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
ENV IS_DOCKER=true
EXPOSE 3000
ENV PORT=3000

View File

@@ -42,19 +42,21 @@ export function resolveSupabaseUrl(url: string | undefined): string | undefined
}
} 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(/\/$/, '');
if (process.env.IS_DOCKER !== 'true') {
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');
}
} 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;