Skip to content

Commit a4a2f02

Browse files
When running wrangler deploy add a OPEN_NEXT_DEPLOY environment variable to let wrangler know that it is being run by open-next (#1023)
1 parent 721bff0 commit a4a2f02

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

.changeset/mighty-heads-shine.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+
When running `wrangler deploy` add a `OPEN_NEXT_DEPLOY` environment variable to let wrangler know that it is being run by open-next

packages/cloudflare/src/cli/commands/deploy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ export async function deployCommand(args: WithWranglerArgs<{ cacheChunkSize?: nu
5656
],
5757
{
5858
logging: "all",
59+
env: {
60+
// If we are running the deploy command we set this OPEN_NEXT_DEPLOY environment variable
61+
// to let `wrangler deploy` know that it is being run from open-next. We do this because
62+
// otherwise `wrangler deploy` run in an open-next project would call
63+
// `opennextjs-cloudflare deploy` (thus causing an unwanted recursion).
64+
OPEN_NEXT_DEPLOY: "true",
65+
},
5966
}
6067
);
6168
}

packages/cloudflare/src/cli/utils/run-wrangler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type WranglerOptions = {
1313
environment?: string;
1414
configPath?: string;
1515
logging?: "all" | "error";
16+
env?: Record<string, string>;
1617
};
1718

1819
/**
@@ -79,6 +80,7 @@ export function runWrangler(options: BuildOptions, args: string[], wranglerOpts:
7980
stdio: shouldPipeLogs ? ["ignore", "pipe", "pipe"] : "inherit",
8081
env: {
8182
...process.env,
83+
...wranglerOpts.env,
8284
// `.env` files are handled by the adapter.
8385
// Wrangler would load `.env.<wrangler env>` while we should load `.env.<process.env.NEXTJS_ENV>`
8486
// See https://opennext.js.org/cloudflare/howtos/env-vars

0 commit comments

Comments
 (0)