Skip to content

Commit

Permalink
Add support for wrangler environment selection in next dev mode (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmif authored Jan 10, 2025
1 parent a816233 commit 41c55a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lemon-zoos-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

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.
5 changes: 4 additions & 1 deletion packages/cloudflare/src/api/get-cloudflare-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ async function getCloudflareContextInNextDev<
const { getPlatformProxy } = await import(
/* webpackIgnore: true */ `${"__wrangler".replaceAll("_", "")}`
);
const { env, cf, ctx } = await getPlatformProxy();
const { env, cf, ctx } = await getPlatformProxy({
// This allows the selection of a wrangler environment while running in next dev mode
environment: process.env.NEXT_DEV_WRANGLER_ENV,
});
global[cloudflareContextInNextDevSymbol] = {
env,
cf: cf as unknown as CfProperties,
Expand Down

0 comments on commit 41c55a8

Please # to comment.