fix: resolve mixed content errors by synchronizing client supabase URL protocol with window location protocol
All checks were successful
Staging Build / build (push) Successful in 2m18s

This commit is contained in:
DanielS
2026-06-24 00:57:22 +02:00
parent 5662b9f770
commit 47664c0aae
4 changed files with 18 additions and 52 deletions

View File

@@ -19,12 +19,23 @@ export function resolveSupabaseUrl(url: string | undefined): string | undefined
const parsed = new URL(url);
if (parsed.hostname === 'supabase-kong' || parsed.hostname === 'kong') {
parsed.hostname = window.location.hostname;
parsed.protocol = window.location.protocol;
return parsed.toString().replace(/\/$/, '');
}
// Mitigate Mixed Content: if the site is HTTPS, force Supabase to HTTPS
if (window.location.protocol === 'https:' && parsed.protocol === 'http:') {
parsed.protocol = 'https:';
return parsed.toString().replace(/\/$/, '');
}
} catch {
return url
let resolved = url
.replace('//supabase-kong', `//${window.location.hostname}`)
.replace('//kong', `//${window.location.hostname}`);
if (window.location.protocol === 'https:') {
resolved = resolved.replace('http://', 'https://');
}
return resolved;
}
}
return url;