Ship Steam login, D1 player sync, and cached「我」dashboard.
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>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user