d68f003000
CI / Change detection (push) Has been cancelled
CI / Version drift (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Workflow RLM cache (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / npm wrapper smoke (push) Has been cancelled
CI / Mobile runtime smoke (push) Has been cancelled
CI / Workflow lint (push) Has been cancelled
CI / Documentation (push) Has been cancelled
Web Frontend / Lint & Type Check (push) Failing after 1s
Auto-close harvested PRs / close (push) Failing after 1s
cargo-deny / cargo-deny (bans licenses sources) (push) Failing after 1s
Security audit / cargo-audit (push) Failing after 1s
Sync to CNB / sync (push) Failing after 1s
cargo-deny / cargo-deny (advisories) (push) Failing after 3s
Web Frontend / Deploy to Cloudflare (push) Has been cancelled
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { getAgentEnv, deleteSession } from "@/lib/community-agent";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
const ALLOWED_LOCALES = new Set(["en", "zh"]);
|
|
|
|
function pickLocale(value: string | null | undefined): string {
|
|
if (!value) return "en";
|
|
return ALLOWED_LOCALES.has(value) ? value : "en";
|
|
}
|
|
|
|
export async function POST(req: Request) {
|
|
const env = await getAgentEnv();
|
|
const url = new URL(req.url);
|
|
const locale = pickLocale(url.searchParams.get("locale"));
|
|
|
|
const cookieHeader = req.headers.get("cookie") ?? "";
|
|
let sid: string | undefined;
|
|
for (const c of cookieHeader.split(";")) {
|
|
const [name, ...rest] = c.trim().split("=");
|
|
if (name === "mt_sid") {
|
|
sid = rest.join("=");
|
|
break;
|
|
}
|
|
}
|
|
|
|
await deleteSession(env.CURATED_KV, sid);
|
|
|
|
const res = NextResponse.redirect(new URL(`/${locale}/admin`, req.url), {
|
|
status: 303,
|
|
headers: { "Cache-Control": "no-store" },
|
|
});
|
|
res.cookies.set("mt_sid", "", {
|
|
path: "/",
|
|
httpOnly: true,
|
|
secure: true,
|
|
sameSite: "strict",
|
|
maxAge: 0,
|
|
});
|
|
return res;
|
|
}
|