由于前后端分离的部署情况,后台设置了允许跨域请求
在测试环境中发现,被拦截器拦截的请求response的header并没有设置跨域。
这是个没注意到坑,补上代码
//拦截器跨域请求设置
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
网友评论