simple-fs-server/routes/api/logout.ts

17 lines
464 B
TypeScript
Raw Normal View History

2023-01-05 18:18:07 +09:00
import { Handlers } from "$fresh/server.ts";
import { deleteCookie } from "http/cookie.ts";
import { Status } from "http/http_status.ts";
export const handler: Handlers = {
GET(req) {
const url = new URL(req.url);
const headers = new Headers(req.headers);
deleteCookie(headers, "auth", { path: "/", domain: url.hostname });
headers.set("location", "/");
return new Response(null, {
status: Status.Found,
headers,
});
},
};