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

18 lines
465 B
TypeScript
Raw Permalink 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,
});
},
2023-01-06 18:24:27 +09:00
};