解决跨域问题 Response to preflight request doesn't pass access control check

简介: 解决跨域问题 Response to preflight request doesn't pass access control check

正文


对于前后端分离,跨域问题老生常谈了,问题是这样的:


Access to fetch at 'https://xxx/api/user' from origin 'http://h5.xxx.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values 'http://h5.xxx.com, *', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.


Google 翻译一下:


从源 http://h5.xxx.com 访问 https://xxx/api/user 处的访存已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:Access-Control-Allow-Origin 标头包含多个值 http://h5.xxx.com, *,但仅允许一个。 让服务器发送带有有效值的标头,或者,如果不透明的响应满足您的需要,请将请求的模式设置为 no-cors,以在禁用 CORS 的情况下获取资源。


原因是就是在服务器设置了允许跨域,同时又在 Nginx 代理又设置了一次。

只要移除其一即可解决。


目录
相关文章
|
4月前
|
JavaScript 前端开发
has been blocked by CORS policy: The ‘Access-Control-Allow-Origin‘ header contains multiple values ‘
has been blocked by CORS policy: The ‘Access-Control-Allow-Origin‘ header contains multiple values ‘
49 0
remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2
remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2
3620 0
|
4月前
|
JSON 数据格式
axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
|
9月前
|
前端开发 JavaScript
ajax请求的重定向处理--Request header field x-requested-with is not allowed by Access-Control-Allow-Header
ajax请求的重定向处理--Request header field x-requested-with is not allowed by Access-Control-Allow-Header
319 0
|
前端开发 数据可视化 Java
报错:跨域问题解决 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
报错:跨域问题解决 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
1089 0
|
应用服务中间件
returned a response status of 405 Method Not Allowed
returned a response status of 405 Method Not Allowed
returned a response status of 405 Method Not Allowed
|
开发工具 git
解决:The requested URL returned error: 403
今天在 arm 架构的服务器上创建工程时,遇到了一个报错,执行的命令如下: git clone git.liuzhen007.com/boffmpeg.gi… 报错信息如下: fatal: unable to access 'git.liuzhen007.com/boffmpeg.gi…': The requested URL returned error: 403
2237 0
|
JavaScript 应用服务中间件 nginx
Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight respo
Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight respo
Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight respo
|
Web App开发 应用服务中间件
tomcat报错:Error parsing HTTP request header
tomcat报错:Error parsing HTTP request header
250 0