Answer the question
In order to leave comments, you need to log in
How to pass cookies from a server written in Golang to a ReactJS application if there is CORS between them?
There was a problem. There is a server application written in Go that performs API functions. And there is a ReactJS application. They are located at different addresses, respectively, they have CORS. Well, so be it, allowed such a relationship between them, but it is assumed that Go passes the cookie to the browser and then uses this state for further actions. And the cookie is passed to the browser if we just pull the appropriate request through the browser. But from a React application, the same request does not lead to such a result. Response received, but no cookie. It's all about CORS.
Here's what to do - I don't know. Maybe I'm going in the wrong direction? Maybe you need to generate a cookie in the React application based on some data received from the server? Should I use JWT? Give a hint.
Answer the question
In order to leave comments, you need to log in
in order for the browser to save the cookies that the server sends us. 4 headers required
to send cookies in your requests you must check
withCredentials: true
$.ajax({
xhrFields: { withCredentials: true },
});
Wrap the API in a React application - mount it on the same server (so that the domain address is the same) and that's it.
at one time, I just turned off security in the browser for development, I don’t know if it will start with your backend, but it should)
supposed to help
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question