๐Ÿ‘€ Our most exciting product launch yet ๐Ÿš€ Join us May 8th for Sanity Connect

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?