Players get a fast TTL-backed homepage (local profile / Cloudflare D1) with dense UI polish; login unlocks /home without blocking on every OpenDota refresh. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
926 B
JavaScript
35 lines
926 B
JavaScript
/**
|
|
* POST|GET /api/auth/logout — clear session cookie.
|
|
*/
|
|
import { jsonResponse, sessionCookieHeaderForRequest } from "./_steam_common.js";
|
|
|
|
function clear(context) {
|
|
const origin = new URL(context.request.url).origin;
|
|
const wantsHtml = (context.request.headers.get("Accept") || "").includes("text/html");
|
|
if (wantsHtml || context.request.method === "GET") {
|
|
return new Response(null, {
|
|
status: 302,
|
|
headers: {
|
|
Location: `${origin}/`,
|
|
"Set-Cookie": sessionCookieHeaderForRequest(context.request, "", { clear: true }),
|
|
"Cache-Control": "no-store",
|
|
},
|
|
});
|
|
}
|
|
return jsonResponse(
|
|
{ ok: true },
|
|
200,
|
|
{
|
|
"Set-Cookie": sessionCookieHeaderForRequest(context.request, "", { clear: true }),
|
|
}
|
|
);
|
|
}
|
|
|
|
export async function onRequestGet(context) {
|
|
return clear(context);
|
|
}
|
|
|
|
export async function onRequestPost(context) {
|
|
return clear(context);
|
|
}
|