0

I have a request that I'm making via fetch(url). It doesn't seem like my cookies that I have are being passed along?

What is the canonical way of doing this? Should I pass document.cookie to the fetch request?

2 Answers 2

2

You need credentials: 'include' in the init object you pass as the second arg to fetch(…):

fetch(url, { credentials: 'include' }) 
Sign up to request clarification or add additional context in comments.

Comments

1

Use credentials in the options object passed to the second parameter:

fetch('url', { credentials: 'include' }) 

credentials also takes same-origin, which only sends cookies which match the domain of the URL requested.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.