server/api/api/auth/mastodon-logout/index.ts
2024-08-27 16:37:23 +02:00

32 lines
804 B
TypeScript

import { apiRoute, applyConfig } from "@/api";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({
allowedMethods: ["POST"],
ratelimits: {
max: 4,
duration: 60,
},
route: "/api/auth/mastodon-logout",
auth: {
required: false,
},
});
/**
* Mastodon-FE logout route
*/
export default apiRoute((app) =>
app.on(meta.allowedMethods, meta.route, () => {
return new Response(null, {
headers: {
Location: "/",
"Set-Cookie": `_session_id=; Domain=${
new URL(config.http.base_url).hostname
}; SameSite=Lax; Path=/; HttpOnly; Max-Age=0; Expires=${new Date().toUTCString()}`,
},
status: 303,
});
}),
);