memorium/routes/api/auth/logout.ts

23 lines
499 B
TypeScript
Raw Normal View History

2024-06-21 11:36:23 +02:00
import { deleteCookie } from "@std/http/cookie";
2023-08-04 22:35:25 +02:00
import { Handlers } from "$fresh/server.ts";
export const handler: Handlers = {
GET(req) {
const url = new URL(req.url);
const redirect = decodeURIComponent(url.searchParams.get("redirect") || "");
2023-08-04 22:35:25 +02:00
const headers = new Headers();
headers.append("location", redirect || "/");
2023-08-04 22:35:25 +02:00
deleteCookie(headers, "session_cookie", {
path: "/",
});
return new Response(null, {
headers,
status: 302,
});
},
};