Hello everyone,
New to developing, NodeJS and Express here (also not english native). I am stuck on a project where i got a frontend app (living on localhost:3000) and a backend app (living on localhost:5000) and i am trying to send a patch request to my server using Axios. i configured my backend app the following way:
app.use(cors(
{
methods: "HEAD,GET,PUT,PATCH,POST,UPDATE,DELETE",
origin: "*",
preflightContinue: true,
},
));
Here my axios call.
const handleSubmit = (e) => {
e.preventDefault();
axios
.patch(
`${process.env.REACT_APP_API}/user/update/${id}`, user)
.then((res) => {});
closeModal(true);
};
Still, when the call runs, i've got CORS error: PATH method not allowed.
I tested my backend code using POSTMAN client and it worked.
What can i do to fix this error in my code?
Thank you for your answers. 🙂