Hi I have a function that posts to a database if a file hash has changed. It then sends back a response with a date either now if it was changed, or whatever was in the db if it hasn't changed. And it posts the new hash and date to the db.
But I would like it to not post if the website isn't being built on Vercel. Effectively only modifying the db if I have chosen to deploy the website.
#How to check if code is being built on Vercel?
5 messages · Page 1 of 1 (latest)
if (hash changed && deploying on vercel)
post
}
if im making some sort of architectural error tell me id rather fix it than make something bad work
I added an env variable like this
"vercel-build": "VERCEL_DEPLOY=true prisma generate && next build",
then checked if it was equal to true in the code
if (process.env.VERCEL_DEPLOY === "true") {
post();
}
You automatically have the variable VERCEL when deploying on vercel https://vercel.com/docs/concepts/projects/environment-variables/system-environment-variables#system-environment-variables