0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-10 22:38:53 -05:00
astro/packages/integrations/vercel/src/lib/env.ts
2023-05-15 14:13:47 +08:00

15 lines
486 B
TypeScript

/**
* 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;
}