fix: prevent resolving internal supabase urls to localhost inside docker container
All checks were successful
Staging Build / build (push) Successful in 3m37s
All checks were successful
Staging Build / build (push) Successful in 3m37s
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user