CORS withCredentials XHR preflight not posting Cookies in Firefox

前端 未结 2 834
遇见更好的自我
遇见更好的自我 2021-02-05 09:52

I\'m trying to do a CORS XHR post w/ credentials. It works great in Chrome, but not in Firefox. The cookies are not present in the pre-flight request headers, and so I\'m seei

相关标签:
2条回答
  • 2021-02-05 10:38

    Now Chromium(the 4th of July 2014) doesn't sent cookie with a preflight request. https://code.google.com/p/chromium/issues/detail?id=377541

    0 讨论(0)
  • 2021-02-05 10:51

    Per spec at https://www.w3.org/TR/cors/#resource-preflight-requests the preflight request never includes cookies. Specifically, the spec says:

    • Exclude user credentials.

    and that links to https://www.w3.org/TR/cors/#user-credentials which says:

    The term user credentials for the purposes of this specification means cookies, HTTP authentication, and client-side SSL (...).

    That said, the code snippet you quote above shouldn't involve a preflight at all: there are no upload event listeners, the method is as simple method, and there are no author headers set. So if you're really seeing a preflight request, the first question is why that's happening. Do you have any extensions in Firefox that might be munging your XMLHttpRequest object?

    0 讨论(0)
提交回复
热议问题