nomadro/apps/nomadvip/app/api/auth/email/route.ts
eric 56b29205e7 Integrate four verticals into nomadro portal with shared packages and API gateway.
Mount /vip with nomadvip+payjsapi, add @nomadro/pay|pb|sdk, apps/api, /admin shell, and backup/rollback scripts under git.nomadro.cn workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 20:16:44 -05:00

20 lines
710 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 从 Cookie 读取邮箱(不调用 PB),用于 emailLinked=1 但 userName 被覆盖的场景
*/
import { NextRequest, NextResponse } from "next/server";
import { COOKIE_NAME } from "@vip/app/lib/auth-cookie";
export async function GET(request: NextRequest) {
const cookie = request.cookies.get(COOKIE_NAME)?.value;
if (!cookie) {
return NextResponse.json({ ok: true, email: null });
}
try {
const payload = JSON.parse(Buffer.from(cookie, "base64url").toString("utf-8"));
const email = payload?.email ?? null;
return NextResponse.json({ ok: true, email: typeof email === "string" ? email : null });
} catch {
return NextResponse.json({ ok: true, email: null });
}
}