I am getting the title error after running the following function in React:
const postToApi = (event) => {
event.preventDefault();
axios.post(process.env.API_POST_URL, {step : "3"})
// API_POST_URL: http://localhost:4000/api/donate
.then(res => {
console.log(res);
console.log(res.data);
})
};
My React app is on localhost:3000. Mentioning this because the file causing the error is: isURLSameOrigin.js:51
"proxy": "http://localhost:4000"
property to your package.json file. – alegriaAccess to XMLHttpRequest at 'http://localhost:4000/api/donate' 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.
– Sean D