I need to make a request using fetch() to a page that sets cookies and then redirects you to another page.
The problem is that the cookies set on the first page don’t persist to the redirect page. I can’t disable the redirect to get the cookies myself
as redirect: ‘manual’ from the fetch API doesn’t do anything
The full documentation for fetch can be found here.
I did some quick googling, and some guy in this thread has a possible solution for your issue. Last, you could also manually extract the cookie from the response object, and send it as a header in a new
fetch call, there seems to be tonnes of options.
Hi, thanks for your response.
The problem is I cannot get the response object where the cookie is set because fetch will automatically follow the redirect. The fetch documentation says you can use redirect:‘manual’ to stop this automatic redirect but it does not work in Fuse (It works in chrome devtools)
- Request to page. Response is 301 with the Set-Cookie header set (I need the value of this).
- fetch follows redirect URL
- Response object from the redirect is returned
I googled and found this on your forums which seems to be the exact same problem as I’m having: https://www.fusetools.com/community/forums/bug_reports/fetch_always_follows_redirects_but_does_not_persis
Thanks for finding the other thread. Following that, I found an internal ticket and linked it to this forum thread.
Currently there’s not much you can do about it, but we’ll keep you informed once the underlying API changes.
Perhaps you could look into using XMLHttpRequest polyfill instead?