chefbible/src/routes/logout/+server.ts
2025-09-03 12:26:07 -04:00

32 lines
1.1 KiB
TypeScript

import type { RequestHandler } from './$types';
import { redirect } from '@sveltejs/kit';
import { dev } from '$app/environment';
export const POST: RequestHandler = async ({ cookies }) => {
// Clear the authentication cookie using the new API
cookies.set('chef_bible_auth', '', {
path: '/',
httpOnly: true,
sameSite: 'lax', // Changed from 'strict' to 'lax' for mobile Safari compatibility
secure: !dev, // Secure in production, not secure in development
maxAge: 0 // Expire immediately
});
// Redirect to home page
throw redirect(302, '/');
};
export const GET: RequestHandler = async ({ cookies }) => {
// Clear the authentication cookie using the new API
cookies.set('chef_bible_auth', '', {
path: '/',
httpOnly: true,
sameSite: 'lax', // Changed from 'strict' to 'lax' for mobile Safari compatibility
secure: !dev, // Secure in production, not secure in development
maxAge: 0 // Expire immediately
});
// Redirect to home page
throw redirect(302, '/');
};