🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Uncaught Error: Network Error While Attempting to Reach https://00000000.apicdn.sanity.io/v1/data/query/production

3 replies
Last updated: Aug 7, 2020
I'm having trouble with the sanity javascript sdk in nextjs. Other calls work (see the movies json) but the sanity calls only work if I make them in getServerSideProps.

Seems like the sdk doesnt play so well with nextjs. Is that expected?

Any help appreciated. Thanks

I'm getting
Uncaught Error: Network error while attempting to reach

async componentDidMount() {
    const transcriptQuery = `*[_type == "candidate" && _id == $cid] {
    const data = await fetch('<https://jsonplaceholder.typicode.com/posts').then(response> => response.json());
    // const transcript = await sanity.fetch(transcriptQuery, { cid: 'cbadb288-9700-47c5-a99f-78f7b990f77e' });
    // console.log(transcript);

Aug 7, 2020, 3:45 PM
Actually its not just through the sdk, its any call that does not originate from the getServerSideProps initial method
Aug 7, 2020, 3:48 PM
Could it be a CORs issue? https://www.sanity.io/docs/cors
Aug 7, 2020, 3:48 PM
seems that was it 🤦.Thanks.
Aug 7, 2020, 3:55 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?