diff --git a/.changeset/blue-moons-cough.md b/.changeset/blue-moons-cough.md new file mode 100644 index 000000000..d27e3e48b --- /dev/null +++ b/.changeset/blue-moons-cough.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vercel': patch +--- + +Fix vercel edge private environment variables usage diff --git a/packages/integrations/vercel/src/edge/adapter.ts b/packages/integrations/vercel/src/edge/adapter.ts index 411717a41..a2e937987 100644 --- a/packages/integrations/vercel/src/edge/adapter.ts +++ b/packages/integrations/vercel/src/edge/adapter.ts @@ -85,6 +85,13 @@ export default function vercelEdge({ vite.ssr ||= {}; vite.ssr.target ||= 'webworker'; + + // Vercel edge runtime is a special webworker-ish environment that supports process.env, + // but Vite would replace away `process.env` in webworkers, so we set a define here to prevent it + vite.define = { + 'process.env': 'process.env', + ...vite.define, + }; } }, 'astro:build:done': async ({ routes }) => {