Make sure that in your fetch() call, you pass the option credentials: 'include' like this:
fetch()
credentials: 'include'
await fetch("url", { credentials: 'include' })
This is needed when the origin of the request is different from the target (API).