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?
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)
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
yeah, your env should be specified per environment — you can add env on vercel so it’s available there
oh nice! didnt knew I could do that. Thanks alot
good luck w your project!
thanks, it was an old project. came back to today and found that projectid in my github visible lol
so build was successful on vercel but data is not coming from sanity now....
can you show the code where you initiate the client?
all of my code is on github
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
import sanityClient from '@sanity/client'
export default sanityClient({
  projectId: process.env.NEXT_PUBLIC_PROJECT_ID, 
  dataset: 'production',
  useCdn: true
})
so its like that?
yeah
yeah it worked! thanks

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?