This is my api url: http://localhost:8000/my-api/ when I am trying to sent get or post request from my fontend reactjs apps, I am getting this error Access to XMLHttpRequest at 'http://localhost:8000/my-api/' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
here is my code:
const SubmitContact = async (e)=>{
e.preventDefault()
const contact = {contact_name:contact_name,contact_email:contact_email,contact_body:contact_body}
await axios.post("http://localhost:8000/my-api/", JSON.stringify(contact)}
I also tried to add proxy in my package.json but didn't work. When I used post man for my api testing it's worked but I don't know why it's not working in reactjs.
Top comments (0)