I have a Next.js application running locally on http://localhost:3000/
and a Java backend on http://localhost:8080/
. I also have a text Editor service running on https://localhost:44349
, and this text Editor service is embeded in my Nextjs application using iFrame.
When an Axios request is sent from the frontend, the request headers are getting set automatically to Access-Control-Allow-Origin to iFrame source instead of backend source, and this is resulting in a CORS error.
If I remove the iFrame, everything works fine, but how can I resolve the error with the iFrame please?
The Error:
Access to XMLHttpRequest at 'http://localhost:8080/Alerts' from origin 'http://localhost:3000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://localhost:44349' that is not equal to the supplied origin.
Zamni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5