M0 (product shell / user entry): /login page, app-shell nav with current user + role + logout, real project list (replaces hardcoded demoProjects), create-project + auto first-version, role-aware home entries. Auth uses native-form + 303 PRG redirect + HttpOnly huijing_api_token cookie; new proxies for auth(login/logout/me) and projects(create/version). M1 (creator flow): surface deterministic-generator demo label; switch prompt/save/compile routes from raw-JSON passthrough to PRG redirect back to workbench + status banner; 401/403 -> /login, empty-state create-version fallback. M1-T5 (per-version playable preview) deferred to M2 (Path A): verified blockers = stub logic compiler + no package-serving endpoint + tested S2 boundary; workbench honestly labels preview as a later capability and links the fixture as a clearly-marked platform sample (no orphan jump, S2 boundary untouched). Verification (@huijing/web): typecheck + lint + 88 unit tests + next build + git diff --check all green. End-to-end (DB-backed create/generate/save/compile) requires real Postgres and is not claimed verified in-sandbox. Docs: docs/agent-specs/2026-06-06-MVP用户可试用M0M1-执行版.md (execution plan + status), docs/agent-specs/2026-06-06-M1T5预览试玩-审阅版.md (M1-T5 review/decision), docs/memorys/2026-06-06-MVP可试用M0M1执行版.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
12 lines
598 B
TypeScript
12 lines
598 B
TypeScript
import { apiBaseUrlFromEnv, buildLoginProxyRequest, proxyLoginAndSetSessionCookie } from "../../workbench/proxy";
|
||
|
||
// POST /api/auth/login:原生表单提交 → 转发后端 auth/login,成功写 HttpOnly 会话 cookie 并 303 跳工作台;
|
||
// 失败 303 回登录页并带 ?error=invalid 提示。
|
||
export async function POST(request: Request): Promise<Response> {
|
||
const built = await buildLoginProxyRequest({ apiBaseUrl: apiBaseUrlFromEnv(), request });
|
||
return proxyLoginAndSetSessionCookie(built, {
|
||
failureLocation: "/login?error=invalid",
|
||
successLocation: "/workbench"
|
||
});
|
||
}
|