CI / config (push) Canceled after 0s
CI / test-frontend (push) Canceled after 0s
CI / test-rust (push) Canceled after 0s
CI / test-e2e (push) Canceled after 0s
CI / test-e2e-release (push) Canceled after 0s
CI / build (push) Canceled after 0s
CI / release (push) Canceled after 0s
CI / docker (push) Canceled after 0s
CI / docker-website (push) Canceled after 0s
在 401 或 opaque redirect 隐藏登录地址时,直接跳转当前空间登录页,并清理旧 Service Worker,避免停留在空白应用外壳。 Co-Authored-By: Codex <noreply@anthropic.com>
17 lines
599 B
TypeScript
17 lines
599 B
TypeScript
/**
|
|
* Resolve an authentication target for a boot fetch. Safari may hide the
|
|
* Location header on manual redirects, so protected 401 responses need a
|
|
* same-origin fallback instead of leaving the app shell blank.
|
|
*/
|
|
export function authenticationRedirectTarget(
|
|
response: Pick<Response, "status" | "type">,
|
|
locationHeader: string | null,
|
|
baseURI: string,
|
|
): string | null {
|
|
if (locationHeader) return new URL(locationHeader, baseURI).toString();
|
|
if (response.status === 401 || response.type === "opaqueredirect") {
|
|
return new URL(".auth", baseURI).toString();
|
|
}
|
|
return null;
|
|
}
|