How to use Json files as environment variables with vercel #6782
-
Hello! I have just set up Vercel and one of my environment variables on my local directory is |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
You could encrypt the JSON file and add it as an Environment Variable: https://vercel.com/support/articles/how-do-i-workaround-vercel-s-4-kb-environment-variables-limit |
Beta Was this translation helpful? Give feedback.
-
Hi @TravisC671, did you find a solution (or a workaround)? If you did can you please share it here? |
Beta Was this translation helpful? Give feedback.
-
Just wanted to share a solution that I came up with that is a bit simpler than setting up a separate endpoint. You can explicitly pass values from the JSON file that Google provides to the auth client. Your setup will look something like this (with a service account + Google Analytics 4 API as an example, but replace with any Google API): import { GoogleAuth } from 'google-auth-library' // no need to install this library, it comes with @google-analytics/data
import { BetaAnalyticsDataClient } from '@google-analytics/data'
const cli = new BetaAnalyticsDataClient({
auth: new GoogleAuth({
projectId: 'yourprojectid',
scopes: 'https://www.googleapis.com/auth/analytics',
credentials: {
client_email: 'email from json file',
private_key: 'pk from json file'
})
})
// Now you can use the relevant API
cli.runReport({ ... }).then() |
Beta Was this translation helpful? Give feedback.
-
Looks like you can include files with // next.config.js
const nextConfig = {
experimental: {
outputFileTracingIncludes: {
'api/data': ['./secrets.json'],
},
},
} |
Beta Was this translation helpful? Give feedback.
You could encrypt the JSON file and add it as an Environment Variable: https://vercel.com/support/articles/how-do-i-workaround-vercel-s-4-kb-environment-variables-limit