Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

Vercel / Nextjs - How to Grant Access to Vercel

3 replies
Last updated: Aug 12, 2022

I have a project that displays and pulls data perfectly fine in localhost but when I go to deploy via vercel / nextjs it is finding the data as undefined because it doesn't have permission to access the API. How would I grant access to vercel if the deployment stage doesn't have an accessible URL in the format of: protocol://hostname [:port] ?

Aug 12, 2022, 7:25 PM

A few things to check here:1. If your dataset is private you will need to use a token when querying.
2. You can add your vercel domain to your CORS origins like this:

https://*.<http://vercel.app|vercel.app>

Aug 12, 2022, 7:31 PM

I got it working, thank you. I apparently had the server, vercel, and API setup working fine, but I had to predefine each part of my groq query before I returned it in my JSX. Just took a little experimentation. I appreciate the help, thank you 🙂

Aug 12, 2022, 7:53 PM

Awesome! Glad you got it working!

Aug 12, 2022, 8:09 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.