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:
@@ -4,6 +4,7 @@ import { useEffect } from "react";
|
||||
import { createBrowserClient } from "@supabase/ssr";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { signOut } from "@/lib/actions/auth";
|
||||
import { resolveSupabaseUrl } from "@/lib/utils";
|
||||
|
||||
export function InactivityTracker() {
|
||||
const router = useRouter();
|
||||
@@ -12,25 +13,9 @@ export function InactivityTracker() {
|
||||
const supabaseUrl = process.env.SUPABASE_URL || process.env.NEXT_PUBLIC_SUPABASE_URL;
|
||||
const supabaseAnonKey = process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
||||
|
||||
// Supabase URL Auflösung inline
|
||||
let resolvedUrl = supabaseUrl;
|
||||
if (resolvedUrl && typeof window !== "undefined") {
|
||||
try {
|
||||
const parsed = new URL(resolvedUrl);
|
||||
if (parsed.hostname === "supabase-kong" || parsed.hostname === "kong") {
|
||||
parsed.hostname = window.location.hostname;
|
||||
resolvedUrl = parsed.toString().replace(/\/$/, "");
|
||||
}
|
||||
} catch {
|
||||
resolvedUrl = resolvedUrl
|
||||
.replace("//supabase-kong", `//${window.location.hostname}`)
|
||||
.replace("//kong", `//${window.location.hostname}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Browser Client inline erstellen
|
||||
const supabase = createBrowserClient(
|
||||
resolvedUrl!,
|
||||
resolveSupabaseUrl(supabaseUrl)!,
|
||||
supabaseAnonKey!,
|
||||
{
|
||||
cookieOptions: {
|
||||
|
||||
Reference in New Issue
Block a user