diff --git a/apps/infra/net/nginx/configmap-static.yaml b/apps/infra/net/nginx/configmap-static.yaml index b35a116..173d2e2 100644 --- a/apps/infra/net/nginx/configmap-static.yaml +++ b/apps/infra/net/nginx/configmap-static.yaml @@ -430,15 +430,14 @@ data: const newRequest = new Request(targetUrl, { ...request, mode: 'cors', - credentials: 'include', - redirect: 'manual', + redirect: 'error', }) // 请求目标域名,浏览器会自动处理缓存 const response = await fetch(newRequest) - // 当遇到非2XX返回时 全部回退原始请求 防止鉴权、重定向等问题 - if (response.status < 200 || response.status >= 300) throw new Error('PWA-CDN: Non-2xx response detected') + // 检查响应状态 + if (!response.ok) throw new Error('PWA-CDN: Non-2xx response detected') return response } catch (error) { diff --git a/apps/infra/net/nginx/static/sw-cdn.js b/apps/infra/net/nginx/static/sw-cdn.js index 602a381..3ad7bf4 100644 --- a/apps/infra/net/nginx/static/sw-cdn.js +++ b/apps/infra/net/nginx/static/sw-cdn.js @@ -58,15 +58,14 @@ async function handleStaticResource(request, url) { const newRequest = new Request(targetUrl, { ...request, mode: 'cors', - credentials: 'include', - redirect: 'manual', + redirect: 'error', }) // 请求目标域名,浏览器会自动处理缓存 const response = await fetch(newRequest) - // 当遇到非2XX返回时 全部回退原始请求 防止鉴权、重定向等问题 - if (response.status < 200 || response.status >= 300) throw new Error('PWA-CDN: Non-2xx response detected') + // 检查响应状态 + if (!response.ok) throw new Error('PWA-CDN: Non-2xx response detected') return response } catch (error) {