yaobo 7 年之前
父节点
当前提交
21421a44cb
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/main/java/cn/efunbox/audio/aop/CorsFilter.java

+ 2 - 2
src/main/java/cn/efunbox/audio/aop/CorsFilter.java

@@ -28,9 +28,9 @@ public class CorsFilter implements Filter {
 //        System.out.println("access from "+reqs.getHeader("Origin"));
 //        System.out.println("access from "+reqs.getHeader("Origin"));
         response.setHeader("Access-Control-Allow-Origin",reqs.getHeader("Origin")); //直接用"*"无法解决跨域问题
         response.setHeader("Access-Control-Allow-Origin",reqs.getHeader("Origin")); //直接用"*"无法解决跨域问题
         response.setHeader("Access-Control-Allow-Credentials", "true");
         response.setHeader("Access-Control-Allow-Credentials", "true");
-        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, OPTIONS");
+        response.setHeader("Access-Control-Allow-Methods", reqs.getHeader("Access-Control-Request-Method"));
         response.setHeader("Access-Control-Max-Age", "3600");
         response.setHeader("Access-Control-Max-Age", "3600");
-        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, id, token");
+        response.setHeader("Access-Control-Allow-Headers", reqs.getHeader("Access-Control-Request-Headers"));
         chain.doFilter(req, res);
         chain.doFilter(req, res);
     }
     }
     public void init(FilterConfig filterConfig) {}
     public void init(FilterConfig filterConfig) {}