✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

CORS Errors When Trying to Fetch a File Using Capacitor

3 replies
Last updated: Jul 26, 2022
I am writing an app using Capacitor which allows you to use web tech in iOS/Android. But on iOS, the URL schema is capacitor://localhost/PAGE , etc. I am getting CORS errors when I try to fetch a file uploaded to Sanity because I cannot add capacitor://localhost as a valid CORS origin. I am getting
Failed to load resource: Origin <capacitor://localhost> is not allowed by Access-Control-Allow-Origin. Status code: 403

Jul 18, 2022, 7:21 PM
I am looking into this 🙂
Jul 26, 2022, 11:47 AM
So the team has answered and here is our solution:you can add the CORS via Sanity CLI:
sanity cors add <capacitor://localhost>
We might add the functionality in
sanity.io/manage but that’s low on the list, bc we have a solution at hand 🙂
Jul 26, 2022, 2:21 PM
I just added * for now which works but is a bit less safe, but our API is read-only anyway. I just wanted to make sure it got added to your ticket system. Thank you 🙂
Jul 26, 2022, 4:30 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?