Ben Borgers

How to allows CORS on Vercel

April 29, 2020

CORS is a browser feature that blocks HTTP requests from one domain to another, unless the destination has the proper headers set up.

I recently ran into these problems when making an HTTP request from my website to Potion, an API I build for Notion notes.

I fixed it by adding headers to my Vercel deployment that allowed HTTP requests from any domain.

Here's my vercel.json file:

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        {
          "key": "access-control-allow-origin",
          "value": "*"
        }
      ]
    }
  ]
}

More blog posts

Subscribe to my newsletter for a monthly round-up of new blog posts and projects Iā€™m working on!

Twitter ↗ RSS feed ↗