Skip to content

Commit b5cf071

Browse files
committed
fix the encoding of __NEXT_PRIVATE_STANDALONE_CONFIG
1 parent e939d9f commit b5cf071

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

.changeset/good-meals-think.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+
fix the encoding of \_\_NEXT_PRIVATE_STANDALONE_CONFIG
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Use headers to force a dynamic response
2+
import { headers } from "next/headers";
3+
4+
export async function GET() {
5+
const nextConfig = process.env.__NEXT_PRIVATE_STANDALONE_CONFIG
6+
? JSON.parse(process.env.__NEXT_PRIVATE_STANDALONE_CONFIG)
7+
: undefined;
8+
return Response.json({ nextConfig, headers: headers() });
9+
}

examples/api/e2e/base.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ test("generates an og image successfully", async ({ page }) => {
6161
expect(res.headers()["content-type"]).toEqual("image/png");
6262
expect(validateMd5(await res.body(), OG_MD5)).toEqual(true);
6363
});
64+
65+
test("NextConfig", async ({ page }) => {
66+
const res = await page.request.get("/api/buildid");
67+
expect(res.status()).toEqual(200);
68+
const { nextConfig } = await res.json();
69+
expect(nextConfig.output).toEqual("standalone");
70+
});

examples/next-partial-prerendering/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"private": true,
3+
"name": "next-partial-prerendering",
34
"scripts": {
45
"build": "next build",
56
"dev": "next dev --turbo",

packages/cloudflare/src/cli/build/bundle-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
9292
},
9393
define: {
9494
// config file used by Next.js, see: https://github.com/vercel/next.js/blob/68a7128/packages/next/src/build/utils.ts#L2137-L2139
95-
"process.env.__NEXT_PRIVATE_STANDALONE_CONFIG": `${JSON.stringify(nextConfig)}`,
95+
"process.env.__NEXT_PRIVATE_STANDALONE_CONFIG": JSON.stringify(JSON.stringify(nextConfig)),
9696
// Next.js tried to access __dirname so we need to define it
9797
__dirname: '""',
9898
// Note: we need the __non_webpack_require__ variable declared as it is used by next-server:

0 commit comments

Comments
 (0)