I've built a react + express app that makes requests on the client and server sides to an external API (the spotify API).
My server and client are served on different ports (8888 and 3000).
Requests on my server side are working fine and use the standard app.use("*", cors())
options to handle CORS, but axios requests on my client side create a CORS problem:
Access to XMLHttpRequest at "externalURL" from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
My client side requests include an Auth token and headers:
headers: {
'Authorization': 'Bearer ' + authToken,
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
}
I've tried reading some similar posts and the MDN docs on CORS but haven't been able to fix the problem.