vlki / refresh-fetch

Wrapper around fetch capable of graceful authentication token refreshing.
MIT License
84 stars 12 forks source link

fetchJSON: Don't send a `Content-Type` header without a body #18

Closed mnoorenberghe closed 3 years ago

mnoorenberghe commented 3 years ago

The Content-Type request header describes the type of the body so when there is no body (e.g. a GET request) the Content-Type header is inappropriate and leads to CORS issues since Content-Type: application/json prevents a request from being "simple": https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests

vlki commented 3 years ago

Good catch! And thanks a lot for the implementation, merging.