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

How to Ignore Files when Deploying on Vercel

16 replies
Last updated: Apr 15, 2021
if I put the file in gitignore, vercel wouldn't be able to get the file either when building right?
Apr 15, 2021, 4:31 AM
projectId is fine to expose, though if you’d like to hide them you can put them in a env variables (next loads env from a .env.local file)
Apr 15, 2021, 5:10 AM
user G
thanks for the reply. I tried that but vercel is giving an error on build. Since I put env file on gitignore, I dont think it can find projectid value from github
Apr 15, 2021, 5:55 AM
yeah, your env should be specified per environment — you can add env on vercel so it’s available there
Apr 15, 2021, 5:56 AM
oh nice! didnt knew I could do that. Thanks alot
Apr 15, 2021, 6:00 AM
good luck w your project!
Apr 15, 2021, 6:01 AM
thanks, it was an old project. came back to today and found that projectid in my github visible lol
Apr 15, 2021, 6:12 AM
so build was successful on vercel but data is not coming from sanity now....
Apr 15, 2021, 6:14 AM
can you show the code where you initiate the client?
Apr 15, 2021, 6:15 AM
all of my code is on github
Apr 15, 2021, 6:16 AM
are you using the sanity client on the client side as well? you should prefix the var name with
NEXT_PUBLIC
i.e
NEXT_PUBLIC_PROJECT_ID
Apr 15, 2021, 6:17 AM
import sanityClient from '@sanity/client'
export default sanityClient({
  projectId: process.env.NEXT_PUBLIC_PROJECT_ID, 
  dataset: 'production',
  useCdn: true
})
Apr 15, 2021, 6:20 AM
so its like that?
Apr 15, 2021, 6:20 AM
yeah
Apr 15, 2021, 6:21 AM
yeah it worked! thanks
Apr 15, 2021, 6:22 AM

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?