Skip to content

Commit 0a6191d

Browse files
authoredFeb 3, 2025··
fix the encoding of __NEXT_PRIVATE_STANDALONE_CONFIG (#323)
1 parent e939d9f commit 0a6191d

File tree

6 files changed

+31
-1
lines changed

6 files changed

+31
-1
lines changed
 

‎.changeset/good-meals-think.md

+5
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

‎examples/api/app/api/buildid/route.ts

+9
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/cloudflare.spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Cloudflare specific tests.
3+
*
4+
* The tests in this file do not run on Node (`next dev`).
5+
*/
6+
7+
import { test, expect } from "@playwright/test";
8+
9+
test("NextConfig", async ({ page }) => {
10+
const res = await page.request.get("/api/buildid");
11+
expect(res.status()).toEqual(200);
12+
const { nextConfig } = await res.json();
13+
expect(nextConfig.output).toEqual("standalone");
14+
});

‎examples/api/e2e/playwright.dev.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare const process: typeof nodeProcess;
88
*/
99
export default defineConfig({
1010
testDir: "./",
11+
testIgnore: "cloudflare.spec.ts",
1112
/* Run tests in files in parallel */
1213
fullyParallel: true,
1314
/* Fail the build on CI if you accidentally left test.only in the source code. */

‎examples/next-partial-prerendering/package.json

+1
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

+1-1
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)
Please sign in to comment.