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
|
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||||
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
||||||
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
|
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||||
|
ENV IS_DOCKER=true
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
|
|||||||
@@ -42,19 +42,21 @@ export function resolveSupabaseUrl(url: string | undefined): string | undefined
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Server-Side fallback to localhost:8000 (for local development)
|
// Server-Side fallback to localhost:8000 (for local development)
|
||||||
try {
|
if (process.env.IS_DOCKER !== 'true') {
|
||||||
const parsed = new URL(url);
|
try {
|
||||||
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
|
const parsed = new URL(url);
|
||||||
parsed.hostname = 'localhost';
|
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
|
||||||
parsed.port = '8000';
|
parsed.hostname = 'localhost';
|
||||||
return parsed.toString().replace(/\/$/, '');
|
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;
|
return url;
|
||||||
|
|||||||
Reference in New Issue
Block a user