2

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'
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Yaroslav
  • 21
  • 4
  • 1
    It will be good to add the relevant pieces of code and configs here, so people can help you better. – Kris Nov 23 '21 at 12:09
  • What CORS error are you getting? What's the error message in your browser console? – jub0bs Nov 23 '21 at 12:29
  • The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. – Yaroslav Nov 23 '21 at 14:02
  • Sounds like a duplicate of this - https://stackoverflow.com/questions/42803394/cors-credentials-mode-is-include – David Nov 23 '21 at 15:18

0 Answers0