Discussion about error connecting to Sanity API and potential solutions
20 replies
Last updated: Jun 3, 2020
P
Okay, so started a new project just now and can't get it to work at all
Standard init
Used the blog preset
Any clues to what I can try to fix?
Standard init
Used the blog preset
sanity startworks - no problembut when I try to go to the studio it just shows me this error:
An error occured while attempting to reach the Sanity API. It might be that your internet connection is unstable or down. You could try hitting the Retry button to see if it was just a temporary glitch.
May 28, 2020, 4:23 PM
P
...and to add to this: I also tried with another project, and I still get the same error
May 28, 2020, 4:39 PM
J
Are there any console errors? Could be that you need to add
<http://localhost:3333>to CORS list:
sanity cors add <http://localhost:3333>
May 28, 2020, 4:56 PM
D
I'm getting the same problem. Both offline and online. I'm using the sanity.io/create based project for Gridsome (but also cross tested it with the gatsby one) on Netlify and it worked before. Both netlify and local cors are added on the sanity projects.
Had this problem for several hours yesterday already and it reappeared today. Both days it seemed to happen in the afternoon CEST / start of office hours PDT and remained like this for hours (yesterday until after midnight).
Is there any way to debug this?
Is this potentially an issue in the studio as present in the
sanity.io/create or an api endpoint thing?
Asking because cli operations like deploying graphql works
Had this problem for several hours yesterday already and it reappeared today. Both days it seemed to happen in the afternoon CEST / start of office hours PDT and remained like this for hours (yesterday until after midnight).
Is there any way to debug this?
Is this potentially an issue in the studio as present in the
sanity.io/create or an api endpoint thing?
Asking because cli operations like deploying graphql works
May 28, 2020, 6:06 PM
P
user J
No errors in the console
Tried with the
sanity cors add <http://localhost:3333>but I only got the following erorr:
Conflict - Duplicate origin already exists for this project
May 28, 2020, 6:26 PM
P
user Y
I'm not the best friend with the network tab, so I might have misunderstood this, but:4 are blocked
3 return 304
the rest return 200
May 28, 2020, 6:39 PM
P
One sec!
May 28, 2020, 6:40 PM
P
...and a ton of other ones with the blob: prefix between
hopefully this was correct, otherwise tell me and I'll try to send something better!
hopefully this was correct, otherwise tell me and I'll try to send something better!
May 28, 2020, 6:42 PM
P
uBlock OriginBut tried disabling it now, and still no success
May 28, 2020, 6:43 PM
P
Tried with Firefox and it works there
May 28, 2020, 6:44 PM
P
...and now I fixed it on Chrome!
Running Privacy Badger which thought the api call was a "potential tracker" and therefore disabled
Running Privacy Badger which thought the api call was a "potential tracker" and therefore disabled
May 28, 2020, 6:45 PM
Yeah - that sometimes happen. It might help to clean out the Sanity auth cookie
May 28, 2020, 6:46 PM
P
Thanks for the help!
So yeah, for me this is resolved, and let me know if there's any info or something (Browser/Plugin version, etc) that would benefit if I sent for future bugs and so on
So yeah, for me this is resolved, and let me know if there's any info or something (Browser/Plugin version, etc) that would benefit if I sent for future bugs and so on
May 28, 2020, 6:49 PM
D
Yupp, also Privacy Badger here.
Anyone an idea on which part of the contact to <yourappid>.
api.sanity.io and cdn.sanity.io triggers privacy badget to completely block it (red). For things like the sanity-gridsomee example running on netlify, this leads to not just the dashboard being blocked but the site itself opening without any image assets as the gridsome example keeps them in the CDN.
Anyone an idea on which part of the contact to <yourappid>.
api.sanity.io and cdn.sanity.io triggers privacy badget to completely block it (red). For things like the sanity-gridsomee example running on netlify, this leads to not just the dashboard being blocked but the site itself opening without any image assets as the gridsome example keeps them in the CDN.
May 28, 2020, 11:33 PM
J
This is still an issue for me. A bit of a different case however. Hopefully it is alright if I piggy back this thread. I am running a Raspberry Pi as a dev server and I am having this issue. It is both on Chrome and Firefox (with Privacy Badger disabled). I have added Cors for the the local IP (192.168.1.214:3333) and also for http://0.0.0.0:3333 which used adding the --host=0.0.0.0 tag. Still trying to track down the issue but any direction would be appreciated.
Jun 3, 2020, 7:41 PM
J
Access to XMLHttpRequest at 'https://{}.<http://api.sanity.io/v1/versions{}|api.sanity.io/v1/versions{*}>' from origin 'http://192.168.1.214:3333 ' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Jun 3, 2020, 7:43 PM
J
Looks like I'm an idiot. Even though I created an entry for 192.168.1.214:3333 I didn't flip the Enable Authentication switch. That seems to have solved the issue.
Jun 3, 2020, 9:02 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.