边缘浏览器 - 使用跨域请求设置Cookie

时间:2016-06-19 21:38:41

标签: angularjs cookies cors microsoft-edge

作为我正在进行的项目的一部分,我们需要发送跨域请求。 我有以下电话:

$http({
       url: 'http://192.168.1.1/API/Login',
       method: "POST",
       data: {
            password: $scope.pass
       },
       withCredentials: true,
       cached: false,
       headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Accept': 'application/json',
        }
}).then(function successCallback(response) {

}, function errorCallback(response) {

});

当我将请求发送到非原始服务器时,我收到以下响应(来自Wireshark):

POST /API/Login HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Accept-Language: en-US,en;q=0.7,he;q=0.3
Origin: http://myserver.com
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586
Host: 192.168.1.1
Content-Length: 21
Connection: Keep-Alive

{"password":"1234"}

HTTP/1.1 200 OK
Date: Sun, 19 Jun 2016 21:07:52 GMT
Server: Some server (UNIX)

Set-Cookie: Session=308333957
Accept-Ranges: bytes
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://myserver.com
Content-type: application/json
Content-Length: 152

{"key":"abcdefg","name":"Joe","session":"308333957"}

它在Chrome和FireFox中运行得非常好,但在Edge上它有一个CORS错误:

Origin http://myserver.com not found in Access-Control-Allow-Origin header.

顺便说一句,当登录凭据错误且服务器没有返回' Set-Cookie'它工作正常! 认为通过使用' withCredentials = true'我允许在跨域请求中设置Cookie,但它没有帮助(仅限Edge)。

有什么想法吗? 有没有机会在Edge出现错误?我无法找到任何开放的东西。

由于

0 个答案:

没有答案