import { define } from "../utils.ts";
import { clearSessionCookie, destroySession } from "@/lib/auth.ts";
import { devAutoLoginEnabled, devSignOutCookie } from "@/lib/dev-auth.ts";
export const handler = define.handlers({
async GET(ctx) {
await destroySession(ctx.req);
const headers = new Headers({ location: "/login" });
headers.append("set-cookie", clearSessionCookie(ctx.req));
// Without this the dev auto-login would sign us straight back in and the
// login page would be unreachable locally.
if (devAutoLoginEnabled()) headers.append("set-cookie", devSignOutCookie());
return new Response(null, { status: 303, headers });
},
});