Skip to content

Commit c8e00a5

Browse files
committed
Fix cloud app 500s by lazily accessing Cloudflare env bindings
Eagerly reading cfEnv.HYPERDRIVE/LOADER/MARKETING at module load time causes every request to fail with HTTPError 500. Use property getters so bindings are only accessed within a request context.
1 parent 473731b commit c8e00a5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎apps/cloud/src/env.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const server = createEnv(serverShape, {
5858
// ---------------------------------------------------------------------------
5959

6060
export const cf = {
61-
hyperdrive: cfEnv.HYPERDRIVE,
62-
loader: cfEnv.LOADER,
63-
marketing: cfEnv.MARKETING,
64-
} as const;
61+
get hyperdrive() { return cfEnv.HYPERDRIVE; },
62+
get loader() { return cfEnv.LOADER; },
63+
get marketing() { return cfEnv.MARKETING; },
64+
};

0 commit comments

Comments
 (0)