I am developing a React project, when making requests from localhost to api, I receive a 'set-cookie' header in response and i need to set them, but I get an error from CORS. Using CRA, axios. withCredentials is added.
On server side(Flask) added headers Access-Control-Allow-Origin and Access-Control-Allow-Credentials.
Is it a server error or on my local dev server?
Client:
axios.post('https://api.com/login', values,
{ withCredentials: true })
.then((response) => {
setLoading(false);
dispatch(setUser(response.data));
})
.catch((error) => {
setLoading(false);
notification.error(error.response.data.message);
});
Server:
# CORS configuration
crm_application = Flask(__name__)
CORS(
crm_application,
origins=[
"http://localhost:3000",
"https://api.stemlab.by"
],
supports_credentials=True
)
crm_application.config['CORS_HEADERS'] = 'Content-Type'