Home >Backend Development >Golang >Why Is My Browser Rejecting Set-Cookie Headers from Cross-Origin Responses?
Browser Rejects Set-Cookie Header from Cross-Origin Response
You encounter an issue where your front end fails to set an HTTP cookie received from the back end. The issue stems from an improper configuration of 'withCredentials' in the client code.
To resolve this, ensure that 'withCredentials' is set as a property of the request rather than a header. Instead of using:
headers: { Accept: `application/json`, 'Content-Type': 'application/json', withCredentials: true, },
Modify the client code to:
headers: { Accept: `application/json`, 'Content-Type': 'application/json', }, withCredentials: true,
The above is the detailed content of Why Is My Browser Rejecting Set-Cookie Headers from Cross-Origin Responses?. For more information, please follow other related articles on the PHP Chinese website!