解决跨域问题 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 代理又设置了一次。

只要移除其一即可解决。


目录
相关文章
|
12天前
|
前端开发 对象存储 数据安全/隐私保护
阿里云前端直传has been blocked by CORS policy: Response to preflight request doesn‘t pass access control
阿里云前端直传has been blocked by CORS policy: Response to preflight request doesn‘t pass access control
98 2
|
2月前
|
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 ‘
69 0
|
2月前
|
Java 应用服务中间件
HTTP Status 404(The requested resource is not available)
HTTP Status 404(The requested resource is not available)
24 0
|
7月前
|
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……
|
7月前
|
安全 JavaScript 前端开发
No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
|
API
【已解决】No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
303 0
【已解决】No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
|
JavaScript Java 应用服务中间件
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
1756 0
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
|
11月前
|
KVM 虚拟化
成功解决Problem while trying to mount target]\“. HTTP response code is 400
成功解决Problem while trying to mount target]\“. HTTP response code is 400
|
开发工具 数据安全/隐私保护
The request you have made requires authentication. (HTTP 401)
The request you have made requires authentication. (HTTP 401)
1244 0
The request you have made requires authentication. (HTTP 401)