apihub icon indicating copy to clipboard operation
apihub copied to clipboard

CORS policy issue in todos PATCH API

Open HimansuWebCoder opened this issue 1 year ago • 3 comments

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

HimansuWebCoder avatar Sep 06 '24 10:09 HimansuWebCoder

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

Sarthak-ONS avatar Sep 18 '24 18:09 Sarthak-ONS

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.

HimansuWebCoder avatar Sep 19 '24 00:09 HimansuWebCoder

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

wajeshubham avatar Oct 02 '24 08:10 wajeshubham