hiteshchoudhary / apihub

Your own API Hub to learn and master API interaction. Ideal for frontend, mobile dev and backend developers.
https://freeapi.app
Other
6.86k stars 1.09k forks source link

CORS policy issue in todos PATCH API #196

Closed HimansuWebCoder closed 1 month ago

HimansuWebCoder commented 2 months ago

When updated my todo list with patch method this showed me. Solve the Access-Control-Allow-Methods issue. Why this issue came. please solve this.

Access to fetch at 'https://api.freeapi.app/api/v1/todos/66dad45997bedfaf8fdcc000' from origin 'http://localhost:8080' has been blocked by CORS policy: Method patch is not allowed by Access-Control-Allow-Methods in preflight response. Screenshot from 2024-09-06 15-52-13

Screenshot from 2024-09-06 15-53-17

Sarthak-ONS commented 2 months ago

Hi @HimansuWebCoder, Can you please share your cors policy, and your frontend headers

HimansuWebCoder commented 2 months ago

Sure, I set my headers and this is correct application/json I set, Isn't it. But this issue arising again and again.

This is the issue: Access to fetch at 'https://66dae132f47a05d55be64eb1.mockapi.io/api/v1/todos/10' from origin 'null' has been blocked by CORS policy: Method patch is not allowed by Access-Control-Allow-Methods in preflight response.

wajeshubham commented 1 month ago

What's the CORS_ORIGIN env var value in your .env?