ResponseHeaders重复问题

本地测试无问题,但是别人请求说是有跨域问题,翻译问题发现

研究headers发现有重复的地方

研究代码发现SpringBoot项目中配置了Headers,ng也配置了Headers,重复了也就报错了

1
2
3
4
5
6
7
8
9
10
11
public class XssFilter implements Filter {
public void addHeader(HttpServletRequest req,HttpServletResponse response) {
if (!req.getRequestURI().contains("app/customer")) {
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Token, CustomerId");
response.setHeader("Content-Type", "application/json;charset=utf-8");
response.addHeader("Access-Control-Max-Age", "1800");//30 min
};
}
}
1
2
3
4
5
6
7
8
9
10
location /apis/ {
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE' always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Headers' '*' always;
if ($request_method = OPTIONS ) {return 200;}
rewrite ^.+apis/?(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://localhost:8091;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
赏个🍗吧
0%