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
All checks were successful
Staging Build / build (push) Successful in 2m18s
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user