fix: nginx添加CORS头解决前端白屏问题
前端构建产物中的script/link标签带有crossorigin属性, 浏览器加载这些资源时会进行CORS检查。 补充Access-Control-Allow-Origin响应头以支持跨域资源加载。
This commit is contained in:
+2
-1
@@ -33,9 +33,10 @@ server {
|
|||||||
proxy_pass http://backend:8000/health;
|
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)$ {
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
expires 30d;
|
expires 30d;
|
||||||
add_header Cache-Control "public, immutable";
|
add_header Cache-Control "public, immutable";
|
||||||
|
add_header Access-Control-Allow-Origin * always;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user