This commit is contained in:
parent
cf6b20f4a5
commit
e041d41945
|
|
@ -45,18 +45,29 @@ export default async function Login({
|
|||
.eq("is_home", true)
|
||||
.maybeSingle();
|
||||
|
||||
// Define the clearCookies function
|
||||
// Define the clearCookies function for server-side execution
|
||||
const clearCookies = async () => {
|
||||
const storedUrl = localStorage.getItem("supabaseUrl");
|
||||
if (storedUrl) {
|
||||
await fetch(`${storedUrl}/api/clearcookies`, {
|
||||
// From request headers or environment variables
|
||||
let hosturl: string | undefined;
|
||||
|
||||
// Option 1: Get host from request headers (useful for dynamic requests)
|
||||
const hostHeader = req.headers.get('host');
|
||||
if (hostHeader) {
|
||||
hosturl = `http://${hostHeader}`; // Construct full URL
|
||||
} else {
|
||||
// Option 2: Use environment variable as fallback
|
||||
hosturl = process.env.SUPABASE_URL; // Ensure you have this set up in your environment variables
|
||||
}
|
||||
|
||||
if (hosturl) {
|
||||
await fetch(`${hosturl}/api/clearcookies`, {
|
||||
method: "POST",
|
||||
});
|
||||
} else {
|
||||
console.error("Supabase URL is not stored in localStorage");
|
||||
console.error("Host URL is not available");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (!homeWorkspace) {
|
||||
await clearCookies(); // Clear cookies if home workspace is not found
|
||||
return redirect(`/${localeString}/login?message=sessionExpired`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue