Troubleshooting CORS configuration for Sanity with custom domains
8 replies
Last updated: Sep 28, 2021
T
Hello, I have a question about configuring CORS origins. I have a frontend site hosted on netlify, and early on in development I configured my sanity instance to allow the randomly generated domain that netlify generated for the site to connect to the project. Now I have also added a custom domain that I bought on namecheap and setup that domain to point to the netlify site. The problem is that now when I try to whitelist my new custom domain on the sanity CORS page, it doesn’t appear to have any effect, and all my requests are blocked. Can you recommend that I try anything to resolve this problem? Thanks!
Sep 28, 2021, 8:12 PM
T
Hi User! This is what I see
No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Sep 28, 2021, 8:26 PM
T
Hi User! This is what I see
No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Sep 28, 2021, 8:26 PM
T
/#/timeline/National%20Timeline:1 Access to XMLHttpRequest at ‘https://hl710q4f.api.sanity.io/v1/data/query/production?query=*%5B_type%20%3D%3D%20%22post%22%20%26%26%20%24keyword%20in%20categories%5B%5D-%3Etitle%5D%20%7C%20order(date)%7B%0A%20%20title%2Cbody%2CfullBody%2Ccitations%2Cdate%2CmainImage%2C%20categories%0A%7D&%24keyword=%22National%20Timeline%22 ’ from origin ‘https://www.landgrabct.org ’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Sep 28, 2021, 8:28 PM
T
I noticed of course I can create a wildcard entry and it works, but I guess that is not ideal
Sep 28, 2021, 8:30 PM
T
I noticed of course I can create a wildcard entry and it works, but I guess that is not ideal
Sep 28, 2021, 8:30 PM
Hmm, is it possible that you've added
http://instead of
https://? Or maybe something along those lines?
Sep 28, 2021, 8:32 PM
T
OH! I think I got it. I ended up setting up two records, one with www and one without. I was trying to setup something with wildcards like this but it did not work. I guess maybe I misunderstood how * could be used.
https://*<http://landgrabct.org|landgrabct.org>*
Sep 28, 2021, 8:35 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.