Hey guys i was making a MERN stack project so the issue i am facing is that in action creater from react server i have to make a get request to node js server or in short
From http://localhost:3000/ i have to make request to the data i have in http://localhost:5000/api/currentuser
The data stored in nodejs server is {"_id":"5d73fd9003b5302f6b013a46","googleid":"109463598810933991924","__v":0}
which is being fetched from mongodb
So what i did is inside my action creater file
i did like
import axios from "axios";
export const fetchuser = () => {
return async(dispatch)=>{
const res=await axios.get("http://localhost:5000/api/currentuser")
dispatch({
type:'fetchuser',
payload:res.data
})
}
};
but then in my console i faced the error and it says
Access to XMLHttpRequest at 'http://localhost:5000/api/currentuser' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.