关于CORS跨域问题的记录,未解决

前端访问后台服务器进行hdfs文件创建的时候产生了跨域问题报错如下:

Access to fetch at 'http://localhost:8087/api/hdfs/httpfs/Cluster%201/user/1111?op=CREATE&data=true&user.name=****' (redirected from 'http://localhost:8000/api/hdfs/httpfs/Cluster%201/user/1111?op=CREATE') from origin 'http://localhost:8000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

根据网上的方法设置了@CrossOrigin以及header:

      response.setHeader("Access-Control-Allow-Credentials", "true");
      response.setHeader("Access-Control-Allow-Origin", "*");    ------*与具体IP均尝试过
      response.setHeader("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
      response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization, Access-Control-Allow-Credentials");
      response.setHeader("Access-Control-Allow-Credentials", "true");

均未生效,暂时没有解决这个问题,记录一下,等解决了再更新备忘

猜你喜欢

转载自www.cnblogs.com/frogfrog/p/11362196.html