From 9590603621aa423216ac9b823cc3e29433eab7a1 Mon Sep 17 00:00:00 2001 From: hiderfong Date: Sat, 25 Apr 2026 11:04:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20nginx=E6=B7=BB=E5=8A=A0CORS=E5=A4=B4?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=89=8D=E7=AB=AF=E7=99=BD=E5=B1=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前端构建产物中的script/link标签带有crossorigin属性, 浏览器加载这些资源时会进行CORS检查。 补充Access-Control-Allow-Origin响应头以支持跨域资源加载。 --- frontend/nginx.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/nginx.conf b/frontend/nginx.conf index ba1172af..dcbe20b1 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -33,9 +33,10 @@ server { proxy_pass http://backend:8000/health; } - # Cache static assets + # Cache static assets + CORS for crossorigin attribute location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 30d; add_header Cache-Control "public, immutable"; + add_header Access-Control-Allow-Origin * always; } }