How to allows CORS on Vercel

January 26, 2021

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": "*"
        }
      ]
    }
  ]
}

A quick favor: was anything I wrote incorrect or misspelled, or do you still have questions? Please use this form to let me know or ask for help!