Fetch() Doesn’t Send Cookies By Default
Fetch is a lovely little api for making ajax requests. I’ve been using the github/fetch polyfill in lieu of full browser support, but with a recent chrome update all requests were being sent without cookies. At first it seemed to be a strangely obvious glitch in Chrome’s implementation, but the behavior turns out to be according to the spec.
I think it’s an odd default, but I’m sure they had their reasons. The difficulty comes from the fact that the polyfill can’t effectively mimic this behavior. Setting the credentials option to ‘include’ will cause fetch to add the appropriate cookie headers.
In my case all requests go through a central wrapper, so it’s no big deal to add this as the default.
Originally published at esimmler.com.