Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

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

3 replies
Last updated: Aug 7, 2020
Hi,
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
https://00000000.apicdn.sanity.io/v1/data/query/production?query=*%5B_type%20%3D%3D%20%22candidate%22%20%26%26%20_id%20%3D%3D%20%24cid%5D%20%7B%0A%20%20%20%20%20%20transcript%2C%0A%20%20%20%20%7D%5B0...1%5D%0A%20%20%20%20&%24cid=%22cbadb288-9700-47c5-a99f-78f7b990f77e%22


async componentDidMount() {
    const transcriptQuery = `*[_type == "candidate" && _id == $cid] {
      transcript,
    }[0...1]
    `;
    const data = await fetch('<https://jsonplaceholder.typicode.com/posts').then(response> => response.json());
    console.log(data);
    // 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?