import type { RequestHandler } from '@sveltejs/kit';
import { clearTokens } from '$lib/server/beatleaderAuth';

export const GET: RequestHandler = async ({ url }) => {
  // For prerendering, redirect to home page
  const redirectTo = url.searchParams.get('redirect_uri') ?? '/';
  return new Response(null, { status: 302, headers: { Location: redirectTo } });
};

export const POST: RequestHandler = async ({ url, cookies }) => {
  clearTokens(cookies);
  const redirectTo = url.searchParams.get('redirect_uri') ?? '/';
  return new Response(null, { status: 302, headers: { Location: redirectTo } });
};


