import type { APIRoute } from "astro";
import { clearSessionCookie, revokeSession } from "../../lib/auth";

export const prerender = false;

export const POST: APIRoute = async ({ request }) => {
  await revokeSession(request);

  return new Response(null, {
    status: 302,
    headers: {
      Location: "/",
      "Set-Cookie": clearSessionCookie(),
    },
  });
};
