From f764fff64adcee187fd19fb86340959a0fe1d62b Mon Sep 17 00:00:00 2001 From: James Date: Mon, 28 Aug 2023 15:19:01 +0100 Subject: [PATCH] fix: `process.env` not enumerable due to being a proxy (#445) --- .changeset/five-rules-call.md | 5 +++++ .../next-on-pages/src/buildApplication/generateGlobalJs.ts | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/five-rules-call.md diff --git a/.changeset/five-rules-call.md b/.changeset/five-rules-call.md new file mode 100644 index 000000000..3e3134ee0 --- /dev/null +++ b/.changeset/five-rules-call.md @@ -0,0 +1,5 @@ +--- +'@cloudflare/next-on-pages': patch +--- + +Fix `process.env` not being enumerable due to being a proxy. diff --git a/packages/next-on-pages/src/buildApplication/generateGlobalJs.ts b/packages/next-on-pages/src/buildApplication/generateGlobalJs.ts index f4c033fc0..7d28cdead 100644 --- a/packages/next-on-pages/src/buildApplication/generateGlobalJs.ts +++ b/packages/next-on-pages/src/buildApplication/generateGlobalJs.ts @@ -20,6 +20,9 @@ export function generateGlobalJs(): string { env: new Proxy( {}, { + ownKeys: () => Reflect.ownKeys(envAsyncLocalStorage.getStore()), + getOwnPropertyDescriptor: (_, ...args) => + Reflect.getOwnPropertyDescriptor(envAsyncLocalStorage.getStore(), ...args), get: (_, property) => Reflect.get(envAsyncLocalStorage.getStore(), property), set: (_, property, value) => Reflect.set(envAsyncLocalStorage.getStore(), property, value), }),