Facebook Pixel

How do I fix the localhost CORS issue with the Swiggy API?

The cleanest fix is a development proxy. Your bundler or a small backend forwards the request from a server-side origin, avoiding the browser's CORS rules entirely for local development.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Why the Swiggy API Blocks Localhost and How to Work Around It

Because the API checks the Origin header, and localhost is not in its allowed origins. The server does not return the CORS headers the browser needs, so the browser blocks the response, even though the request actually reached the server.

Because Postman is not a browser and does not enforce CORS. The browser blocks the response because the server did not grant your origin permission. The request reaches the server fine; the browser just refuses to hand you the response.

Only for quick testing. It disables CORS in your browser, which works for development but is not a real solution and must never be used in production. Use it sparingly and switch to a proxy as soon as possible.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.