Disabling CORS policies when deploying a python backend

Hey guys,

I am currently trying to deploy my python backend onto vercel. I keep running into a CORS issue when I try to connect my localhost to the python backend. How can I disable cors. I’m using python with FastAPI and I have whitelisted every origin on the FastAPI side. Can anyone show me how to set up the vercel.json file?

The domain troubleshooting guide can help with most custom domain configuration issues. You might be able to use that guide to solve it before a human is available to help you. Then you can come back here and share the answer for bonus points.

You can also use v0 to narrow down the possibilities.

Hi,

You cannot disable CORS completely. Instead you need to enable as per requirement. Learn more here: How can I enable CORS on Vercel?

Hmmmm makes sense. I just need to whitelist my localhost:3000. How can I do that?

Chrome does not support localhost CORS requests, and there is unlikely any change in this direction.

You can use the Allow-Control-Allow-Origin: * Chrome Extension to go around this issue. The extension will add the necessary HTTP Headers for CORS:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: "GET, PUT, POST, DELETE, HEAD, OPTIONS"
Access-Control-Expose-Headers: <you can add values here>

The source code is published on Github.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.