I am using React and node js. The most common solution out there is to add access-control-allow-origin to the code. But I did not understand where and how to put that in my code. Here is my react code for making a post request.
const handleSubmit = (e) => {
e.preventDefault();
fetch("http://localhost:8000/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify("holla"),
});
};
And here is my function for handling post request
router.post("/login", (req, res) => {
console.log(req.body);
return res.redirect("back");
});