火狐CORS请求给予尽管头“跨起源请求阻止” [英] Firefox CORS request giving 'Cross-Origin Request Blocked' despite headers

查看:1152
本文介绍了火狐CORS请求给予尽管头“跨起源请求阻止”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个简单的跨域请求,火狐始终未与此错误阻止它:

I'm trying to make a simple cross-origin request, and Firefox is consistently blocking it with this error:

跨域请求阻止:同源策略不允许读取远程资源在[URL]。这可以由资源移动到相同域或启用CORS固定。 [URL]

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at [url]. This can be fixed by moving the resource to the same domain or enabling CORS. [url]

它工作在Chrome和Safari的罚款。

It works fine in Chrome and Safari.

据我可以告诉我设置我的PHP所有正确的头,让这个工作。下面是我的服务器与响应

As far as I can tell I've set all the correct headers on my PHP to allow this to work. Here's what my server is responding with

HTTP/1.1 200 OK
Date: Mon, 23 Jun 2014 17:15:20 GMT
Server: Apache/2.2.22 (Debian)
X-Powered-By: PHP/5.4.4-14+deb7u8
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type
Access-Control-Request-Headers: X-Requested-With, accept, content-type
Vary: Accept-Encoding
Content-Length: 186
Content-Type: text/html

我试过用角,jQuery和基本XMLHTT prequest对象,像这样:

I've tried using Angular, JQuery and a basic XMLHTTPRequest object, like so:

var data = "id=1234"
var request = new XMLHttpRequest({mozSystem: true})
request.onload = onSuccess;
request.open('GET', 'https://myurl.com' + '?' + data, true)
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
request.send()

...它在不火狐一切正常。任何人都可以在这方面帮助呢?

...and it works in everything that isn't Firefox. Can anyone help with this at all?

推荐答案

原来,这有没有关系CORS-这是与安全证书有问题。误导性的错误=4小时头疼的问题。

Turns out this has nothing to do with CORS- it was a problem with the security certificate. Misleading errors = 4 hours of headaches.

这篇关于火狐CORS请求给予尽管头“跨起源请求阻止”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆