fix: resolve internal supabase-kong urls to external domain
All checks were successful
Staging Build / build (push) Successful in 3m24s
All checks were successful
Staging Build / build (push) Successful in 3m24s
This commit is contained in:
@@ -20,7 +20,11 @@ export function resolveSupabaseUrl(url: string | undefined): string | undefined
|
|||||||
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
|
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
|
||||||
parsed.hostname = window.location.hostname;
|
parsed.hostname = window.location.hostname;
|
||||||
parsed.protocol = window.location.protocol;
|
parsed.protocol = window.location.protocol;
|
||||||
parsed.port = ''; // Port entfernen, da der öffentliche Zugriff über Port 80/443 läuft
|
if (window.location.hostname === 'localhost' && parsed.port === '8000') {
|
||||||
|
parsed.port = '8000';
|
||||||
|
} else {
|
||||||
|
parsed.port = ''; // Port entfernen für Produktion hinter Reverse Proxy
|
||||||
|
}
|
||||||
return parsed.toString().replace(/\/$/, '');
|
return parsed.toString().replace(/\/$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,22 +45,30 @@ export function resolveSupabaseUrl(url: string | undefined): string | undefined
|
|||||||
return resolved;
|
return resolved;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Server-Side fallback to localhost:8000 (for local development)
|
// Server-Side: Umschreiben auf externe URL oder localhost:8000
|
||||||
if (process.env.IS_DOCKER !== 'true') {
|
try {
|
||||||
try {
|
const parsed = new URL(url);
|
||||||
const parsed = new URL(url);
|
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
|
||||||
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
|
if (process.env.NEXT_PUBLIC_SUPABASE_URL_EXTERNAL) {
|
||||||
|
const extUrl = new URL(process.env.NEXT_PUBLIC_SUPABASE_URL_EXTERNAL);
|
||||||
|
parsed.hostname = extUrl.hostname;
|
||||||
|
parsed.port = extUrl.port;
|
||||||
|
parsed.protocol = extUrl.protocol;
|
||||||
|
} else {
|
||||||
parsed.hostname = 'localhost';
|
parsed.hostname = 'localhost';
|
||||||
parsed.port = '8000';
|
parsed.port = '8000';
|
||||||
return parsed.toString().replace(/\/$/, '');
|
parsed.protocol = 'http:';
|
||||||
}
|
}
|
||||||
} catch {
|
return parsed.toString().replace(/\/$/, '');
|
||||||
return url
|
|
||||||
.replace('//supabase-kong:8000', '//localhost:8000')
|
|
||||||
.replace('//kong:8000', '//localhost:8000')
|
|
||||||
.replace('//supabase-kong', '//localhost:8000')
|
|
||||||
.replace('//kong', '//localhost:8000');
|
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
const target = process.env.NEXT_PUBLIC_SUPABASE_URL_EXTERNAL || 'http://localhost:8000';
|
||||||
|
const targetUrl = new URL(target);
|
||||||
|
return url
|
||||||
|
.replace('//supabase-kong:8000', `//${targetUrl.host}`)
|
||||||
|
.replace('//kong:8000', `//${targetUrl.host}`)
|
||||||
|
.replace('//supabase-kong', `//${targetUrl.host}`)
|
||||||
|
.replace('//kong', `//${targetUrl.host}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
|
|||||||
Reference in New Issue
Block a user