Optimize terminal startup and deployment smoke checks

This commit is contained in:
2569718930@qq.com
2026-05-31 01:56:08 +08:00
parent bf0fbe1b1d
commit ca72072da0
21 changed files with 393 additions and 41 deletions
+34 -3
View File
@@ -4,7 +4,6 @@ import {
buildBackendRequestHeaders,
} from "@/lib/backend-auth";
import {
buildProxyExceptionResponse,
buildUpstreamErrorResponse,
} from "@/lib/api-proxy";
import {
@@ -136,6 +135,27 @@ function subscriptionRequiredAuthProfileResponse({
return applyAuthResponseCookies(inactive, response);
}
function unauthenticatedAuthProfileResponse({
reason,
response,
}: {
reason: string;
response: NextResponse | null;
}) {
const anonymous = NextResponse.json(
{
authenticated: false,
subscription_active: false,
points: 0,
degraded_auth_profile: true,
degraded_reason: reason,
},
{ headers: { "Cache-Control": "no-store" } },
);
clearEntitlementSnapshotCookie(anonymous);
return applyAuthResponseCookies(anonymous, response);
}
function snapshotAuthProfileResponse({
email,
reason,
@@ -377,8 +397,19 @@ export async function GET(req: NextRequest) {
userId: identity.userId,
});
}
return buildProxyExceptionResponse(error, {
publicMessage: "Failed to fetch auth profile",
const snapshotPayload = entitlementSnapshotToAuthPayload(
readEntitlementSnapshot(req),
);
if (snapshotPayload) {
const snapshotResponse = NextResponse.json({
...snapshotPayload,
entitlement_snapshot_reason: "exception_snapshot",
});
return applyAuthResponseCookies(snapshotResponse, auth?.response || null);
}
return unauthenticatedAuthProfileResponse({
reason: String(error),
response: auth?.response || null,
});
}
}