docs(app): explain route proxy authentication and page composition
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
/**
|
||||
* 公开首页与已登录工作台的服务器分流。Cookie存在不是有效会话证明,需向profile端点验证后才重定向。
|
||||
* 会话无效或服务暂不可达仍显示公开LandingPage,不因为一枚旧Cookie隐藏公开内容。
|
||||
*/
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import LandingPage from "@/components/landing-page";
|
||||
|
||||
/** 异步读取请求Cookie,带15秒时限/禁缓存验证上游;只需成功状态,不消费完整profile JSON。 */
|
||||
export default async function Home() {
|
||||
const session = (await cookies()).get("foundry_session")?.value;
|
||||
let authenticated = false;
|
||||
@@ -15,12 +20,14 @@ export default async function Home() {
|
||||
redirect: "manual",
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
// 按响应状态确定是否已认证,再丢弃不需要的body;此处不解析profile字段。
|
||||
authenticated = response.ok;
|
||||
await response.body?.cancel();
|
||||
} catch {
|
||||
// An unverified session must not hide the public landing page.
|
||||
}
|
||||
}
|
||||
// 仅在确认成功后跳工作台,未认证时沿用同一静态展示组件。
|
||||
if (authenticated) redirect("/dashboard");
|
||||
return <LandingPage />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user