javascript - 未根据 OPTIONS 请求发送 Cookie

标签 javascript angularjs ajax azure cookies

对于我正在开发的 Angular 1 应用程序,使用了 cookie 身份验证。问题是:当进行 OPTIONS 调用时,不会发送 cookie,并且服务器会尝试重定向用户以再次登录。只是想知道,这是谁的“错”?服务器(Azure API 应用程序)还是前端?如果是前端,如何在 OPTIONS 调用中发送 cookie?我正在使用 augular-resource 并配置如下:

$httpProvider.defaults.withCredentials = true

最佳答案

specification says :

Otherwise, make a preflight request. Fetch the request URL from origin source origin using referrer source as override referrer source with the manual redirect flag and the block cookies flag set, using the method OPTIONS, and with the following additional constraints … Exclude user credentials.

and also

The term user credentials for the purposes of this specification means cookies, HTTP authentication, and client-side SSL certificates that would be sent based on the user agent's previous interactions with the origin. Specifically it does not refer to proxy authentication or the Origin header.

因此客户端不应发送 cookie,并且服务器应该能够响应预检请求,而无需首先进行身份验证。

关于javascript - 未根据 OPTIONS 请求发送 Cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41760128/

相关文章:

javascript - 为什么 document.getElementsByClassName 除了第一次之外没有准确获取所有元素?

javascript - 如何使 Internet Explorer 模拟指针事件 :none?

JavaScript 访问调用函数中声明的变量

javascript - 使用 AJAX 刷新的 Wicket 组件 "wicket:head"部分

javascript - 重新加载 DIV 而不重新加载整个页面?

javascript - 通过 AJAX 发布时如何忽略 JSON 数据?

angularjs - 如何使用cypress输入多个具有相同名称的输入实例

javascript - Angular.js 和 DAO 模式

javascript - 了解 Lodash - JavaScript 中的 findwhere 和复制运算符

Ajax 中的 JavaScript - Internet Explorer