summaryrefslogtreecommitdiff
path: root/packages/integrations/vercel/src/lib/env.ts
blob: 01d8c76a5d366aea31501eb25c91dddbfe42f6b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * While Vercel adds the `PUBLIC_` prefix for their `VERCEL_` env vars by default, some env vars
 * like `VERCEL_ANALYTICS_ID` aren't, so handle them here so that it works correctly in runtime.
 */
export function exposeEnv(envs: string[]): Record<string, unknown> {
	const mapped: Record<string, unknown> = {};

	envs
		.filter((env) => process.env[env])
		.forEach((env) => {
			mapped[`import.meta.env.PUBLIC_${env}`] = JSON.stringify(process.env[env]);
		});

	return mapped;
}