#Headers sent via postman and work fine, via react header is empty

10 messages · Page 1 of 1 (latest)

deft wind
#

Here is the code

ts (async () => { fetch("http://localhost:8001/some/url", { headers: {'api-key':'SOMEKYEY'} }) .then(res => res.json())

Via postman the head is recognised and the value process, no issues!

What may be the issue here?

Thanks everyone!

deft wind
#

This is a cors issue probably - note that without sending headers, the requests work fine (via react)

cedar stirrup
#

need to enable credentials: "same-origin" maybe?

#

if you're working with cookies

cedar stirrup
#

from CORS reasons

#

but you'll get an error in your browser console

#

need on the server to set the header to accept requests from your react app

deft wind
#

Hey! thanks ascor! It was cors, yes! I discarded it as I had that taken care of in the backend

#

Problem was it wasn't handling Headers