Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/good-meals-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

fix the encoding of \_\_NEXT_PRIVATE_STANDALONE_CONFIG
9 changes: 9 additions & 0 deletions examples/api/app/api/buildid/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Use headers to force a dynamic response
import { headers } from "next/headers";

export async function GET() {
const nextConfig = process.env.__NEXT_PRIVATE_STANDALONE_CONFIG
? JSON.parse(process.env.__NEXT_PRIVATE_STANDALONE_CONFIG)
: undefined;
return Response.json({ nextConfig, headers: headers() });
}
14 changes: 14 additions & 0 deletions examples/api/e2e/cloudflare.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Cloudflare specific tests.
*
* The tests in this file do not run on Node (`next dev`).
*/

import { test, expect } from "@playwright/test";

test("NextConfig", async ({ page }) => {
const res = await page.request.get("/api/buildid");
expect(res.status()).toEqual(200);
const { nextConfig } = await res.json();
expect(nextConfig.output).toEqual("standalone");
});
1 change: 1 addition & 0 deletions examples/api/e2e/playwright.dev.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ declare const process: typeof nodeProcess;
*/
export default defineConfig({
testDir: "./",
testIgnore: "cloudflare.spec.ts",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand Down
1 change: 1 addition & 0 deletions examples/next-partial-prerendering/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"private": true,
"name": "next-partial-prerendering",
"scripts": {
"build": "next build",
"dev": "next dev --turbo",
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/src/cli/build/bundle-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
},
define: {
// config file used by Next.js, see: https://github.com/vercel/next.js/blob/68a7128/packages/next/src/build/utils.ts#L2137-L2139
"process.env.__NEXT_PRIVATE_STANDALONE_CONFIG": `${JSON.stringify(nextConfig)}`,
"process.env.__NEXT_PRIVATE_STANDALONE_CONFIG": JSON.stringify(JSON.stringify(nextConfig)),
// Next.js tried to access __dirname so we need to define it
__dirname: '""',
// Note: we need the __non_webpack_require__ variable declared as it is used by next-server:
Expand Down