Reputation: 4292
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
Upvotes: 3
Views: 16364
Reputation: 271
Have you recently added the URL to your .env? If so, try stopping your npm/yarn and start it again. Applications compile your .env at the beginning of your dev server. If that does not work have you tried placing the URL directly into it?
Upvotes: 7