CORS issue React/nodejs : origin: '*' doesn't work

41 Views Asked by At

i developping an app using react as frontend, node js as backend and my sql as database. when i'm filling a form to be sent to database trought node js i'm not finding all the data ( it works for some user and some not), secondly i found that i have CORS error, but even if i try to add app.use(cors({origin: '*',methods: "GET,HEAD,PUT,PATCH,POST,DELETE",})); i get the error

Access to XMLHttpRequest at 'https://api.mehdi.com/api/submit-form' from origin 'https://experiments.mehdi.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Knowing that my api (backend) is : https://api.mehdi.com/api/submit-form

and my front end is : https://experiments.mehdi.com

and both are hosted on the same server, is there a solution that i could try to resolve that , and thank you in advance.

0

There are 0 best solutions below