【发布时间】:2012-04-25 09:14:03
【问题描述】:
我正在尝试发布带有凭据的 CORS XHR 帖子。它在 Chrome 中运行良好,但在 Firefox 中则不行。 cookie 不存在于飞行前请求标头中,因此我看到 302。这在 Chrome 中非常有效,因为 cookie 位于飞行前请求标头中,并且随后的 POST 会通过。
为什么这在 FF 中不起作用?我错过了什么?
// assume url, boundEventHandler and uploadData are defined, as this definitely works in Chrome
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.addEventListener ("readystatechange", boundEventHandler, false);
xhr.withCredentials = true; // FWIW, I've also tried the string 'true'
xhr.send(uploadData);
有什么想法吗?我看到一些帖子说我可以在服务器端代理请求,但我更愿意根据 CORS 规范来让它工作。
谢谢!
【问题讨论】:
-
你用的是什么版本的FF,最新的?
标签: html firefox cookies cross-domain