Skip to content Skip to sidebar Skip to footer

Custom Headers Are Not Added To Request Object

I'm trying to use fetch api. First i create a new Headers() object: var oHeaders = new Headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-D

Solution 1:

When you set mode: 'no-cors'for a request, browsers won’t allow you to set any request headers other than CORS-safelisted request-headers. See the spec requirements:

To append a name/value (name/value) pair to a Headers object (headers), run these steps:

  1. Otherwise, if guard is "request-no-cors" and name/value is not a CORS-safelisted request-header, return.

In that algorithm, return equates to “return without adding that header to the Headers object”.

Post a Comment for "Custom Headers Are Not Added To Request Object"