Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

How to Set CORs Origins for Cloudflare Pages

7 replies
Last updated: May 3, 2022
Hey y’all - I’m wondering if there is a way to set CORs origins for cloudflare pages deploy previews with a URL pattern like this
https://{hash}.domain.pages.dev
where the hash is unique for each PR. Here’s an example from the project we’re working on:
https://444238b5.stylitics-demo-beta.pages.dev
May 3, 2022, 9:22 PM
If I’m understanding right you should be able to do it like this:
https://*.<http://domain.pages.dev|domain.pages.dev>
May 3, 2022, 9:25 PM
I’ve tried that and get this err
May 3, 2022, 9:29 PM
That’s really weird, just tested and it worked for me
May 3, 2022, 9:38 PM
Very weird indeed!
May 3, 2022, 9:39 PM
It’s a browser thing (this will work in Chrome but not Firefox). Jacob: Please try in Chrome or using the CLI (
sanity cors add https://*.<http://stylitics-demo-beta.pages.dev|stylitics-demo-beta.pages.dev> --no-credentials
). Apologies for the inconvenience.
May 3, 2022, 10:25 PM
Oh damn! Maybe this will be the nail in the coffin for me leaving FF haha
May 3, 2022, 10:27 PM
Worked like a charm - thanks
user A
!
May 3, 2022, 10:28 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?