I am trying to make a http get request, I am getting on network tab CORS-ERROR.
I am running my client on live-server (http://127.0.0.1:5000/client/contactAdmin.html) and the api I am trying to reach to is (http://localhost:5000/api/form/contactAdmin)
app.use('/api/form', formRoute);
router.get('/contactAdmin', async (req, res) => {
const allForms = await Form.find({});
return res.status(200).json({ allForms });
});
client:
const renderForms = async () => {
try {
const response = await fetch(
'http://localhost:5000/api/form/contactAdmin',
{
method: 'GET',
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
}
);
return response;
} catch (error) {
console.log(error);
}
};
renderForms();