Skip to content

Commit 41c55a8

Browse files
authored
Add support for wrangler environment selection in next dev mode (#243)
1 parent a816233 commit 41c55a8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/lemon-zoos-chew.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
Add support for specifying wrangler environment when using next dev so that bindings and vars are properly loaded. This can be specified with the env variable NEXT_DEV_WRANGLER_ENV.

packages/cloudflare/src/api/get-cloudflare-context.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ async function getCloudflareContextInNextDev<
7171
const { getPlatformProxy } = await import(
7272
/* webpackIgnore: true */ `${"__wrangler".replaceAll("_", "")}`
7373
);
74-
const { env, cf, ctx } = await getPlatformProxy();
74+
const { env, cf, ctx } = await getPlatformProxy({
75+
// This allows the selection of a wrangler environment while running in next dev mode
76+
environment: process.env.NEXT_DEV_WRANGLER_ENV,
77+
});
7578
global[cloudflareContextInNextDevSymbol] = {
7679
env,
7780
cf: cf as unknown as CfProperties,

0 commit comments

Comments
 (0)