From f5ee30e1ca59effc9583f883b3eecada3a759542 Mon Sep 17 00:00:00 2001 From: rohow Date: Mon, 18 Aug 2025 16:53:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(cdn):=20cdn=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/infra/net/nginx/configmap-static.yaml | 7 +++---- apps/infra/net/nginx/static/sw-cdn.js | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) 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) {