Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fa74e70
refactor: remove createServerBundle.ts and integrate its functionalit…
conico974 Jun 27, 2026
33a6eff
feat: implement default overrides for bundle configurations and add t…
conico974 Jun 27, 2026
fe002e1
format
conico974 Jun 27, 2026
9ee9515
fix ts issue
conico974 Jun 27, 2026
6fad0c6
feat: add default overrides for AWS adapter and integrate Cloudflare …
conico974 Jun 27, 2026
84397ab
Revert "feat: add default overrides for AWS adapter and integrate Clo…
conico974 Jun 27, 2026
f22d37f
feat: enhance AWS adapter with default overrides and improve middlewa…
conico974 Jun 27, 2026
a3165f0
refactor(core): return ValidateConfigResult from validateConfig inste…
conico974 Jun 28, 2026
6296e94
refactor(core): extract buildOpenNextOutput, export OpenNextOutput type
conico974 Jun 28, 2026
4e82821
refactor(core): branch on ValidateConfigResult in compileOpenNextConfig
conico974 Jun 28, 2026
0af2e73
feat(core): overridable validateConfig and generic generateOutput on …
conico974 Jun 28, 2026
bab47f1
fix(core): use require.resolve for full-path overrides in resolve plugin
conico974 Jun 28, 2026
51b5e3b
format
conico974 Jun 28, 2026
a437de1
feat(core): enforce mandatory externals in serverBundle and update re…
conico974 Aug 1, 2026
cd8f83e
refactor(core): enhance resolve plugin to support dynamic override re…
conico974 Aug 1, 2026
a63c22b
wip
conico974 Jul 15, 2026
607ce77
fix issue
conico974 Aug 1, 2026
9dd1ad8
feat(routing): add restoreNullOrigin middleware to handle null host h…
conico974 Aug 1, 2026
e9a508b
feat(middleware): add getMiddlewareMatchPath function and update shou…
conico974 Aug 1, 2026
ab7a53e
feat(routing): add ISR support for prerendered routes and update rela…
conico974 Aug 1, 2026
16aae78
refactor(headers): simplify test descriptions and remove deprecated c…
conico974 Aug 1, 2026
5b562ef
feat(routing): ensure single redirect target in response headers
conico974 Aug 1, 2026
65a1153
feat(routing): add support for trailing slash variants in routing con…
conico974 Aug 1, 2026
76c9df5
feat(routing): implement prerender route resolution and update relate…
conico974 Aug 1, 2026
2da77c9
feat(routing): add priority route handling and related tests for redi…
conico974 Aug 1, 2026
c5833a3
feat(routing): implement routing normalization and add related tests
conico974 Aug 2, 2026
9aad41d
Merge remote-tracking branch 'origin/main' into vicb/review-pr-41
vicb Sep 3, 2026
3e90cbf
test(e2e): await middleware rewrite status assertions
vicb Sep 3, 2026
4754266
fix(cloudflare): require the routing adapter contract
vicb Sep 3, 2026
250a003
fix(routing): associate prerenders with adapter outputs
vicb Sep 3, 2026
1440c4b
test(middleware): verify routing config packaging
vicb Sep 3, 2026
def797e
fix(routing): delimit renamed capture references
vicb Sep 3, 2026
2e4dcb5
fix(routing): isolate priority redirect matches
vicb Sep 3, 2026
a37889a
fix(routing): reject stale Next data requests
vicb Sep 3, 2026
436c730
fix(routing): preserve external rewrite queries
vicb Sep 3, 2026
caf9237
test(routing): verify middleware data request URL
vicb Sep 3, 2026
5f7efb3
fix(routing): preserve bodies after middleware
vicb Sep 3, 2026
08f8213
test(core): use the resolver routing shape
vicb Sep 3, 2026
44a04aa
fix(middleware): omit an absent geo city
vicb Sep 3, 2026
ad552f9
fix(routing): serialize headers on forwarded events
vicb Sep 3, 2026
a4779a8
move @next/routing to peer dep
vicb Sep 3, 2026
45d9e38
Merge remote-tracking branch 'origin/main' into vicb/review-pr-41
vicb Sep 3, 2026
c0a5752
use pnpm 11
vicb Sep 3, 2026
1cd0e88
fixup! fmt
vicb Sep 3, 2026
4bdcc40
fixup! bin with pnpm 11
vicb Sep 3, 2026
9d58df4
oxlint: disable eslint(no-param-reassign)
vicb Sep 3, 2026
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
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ runs:
using: composite
steps:
- name: Install pnpm
uses: pnpm/action-setup@v6
uses: pnpm/setup@v2
with:
version: 10
install: false

- name: Install Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v7
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ jobs:
aws-region: us-east-1

- name: Setup pnpm
uses: pnpm/action-setup@v6
uses: pnpm/setup@v2
with:
version: 10
install: false

- name: Set up NodeJS
uses: actions/setup-node@v7
Expand Down
2 changes: 1 addition & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@typescript-eslint/no-redeclare": "error",
"no-unused-vars": "off",
"no-delete-var": "off",
"no-param-reassign": "warn",
"no-param-reassign": "off",
"no-sequences": "warn",
"unicorn/prefer-node-protocol": "error",
"import/first": "error",
Expand Down
2 changes: 1 addition & 1 deletion examples-cloudflare/e2e/app-router/e2e/headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test("Headers", async ({ page }) => {
expect(headers["x-opennext-requestid"]).not.toBeFalsy();
});
/**
* Tests that the middleware headers are applied after next.config.js headers. Requires 'dangerous.middlewareHeadersOverrideNextConfigHeaders' to be set.
* Tests that the middleware headers are applied after next.config.js headers.
*/
test("Middleware headers override next.config.js headers", async ({ page }) => {
const responsePromise = page.waitForResponse((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ test("Middleware Rewrite Status Code", async ({ page }) => {
await page.goto("/rewrite-status-code");
const el = page.getByText("Rewritten Destination", { exact: true });
await expect(el).toBeVisible();
expect(statusPromise).resolves.toEqual(403);
await expect(statusPromise).resolves.toEqual(403);
});
8 changes: 1 addition & 7 deletions examples-cloudflare/e2e/app-router/open-next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,4 @@ const baseConfig = defineCloudflareConfig({
queue: queueCache(doQueue),
});

export default {
...baseConfig,
dangerous: {
...baseConfig.dangerous,
middlewareHeadersOverrideNextConfigHeaders: true,
},
};
export default baseConfig;
2 changes: 1 addition & 1 deletion examples-cloudflare/e2e/app-router/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function middleware(request: NextRequest) {
// Response headers should show up in the client's response headers
responseHeaders.set("response-header", "response-header");

// For dangerous.middlewareHeadersOverrideNextConfigHeaders we need to verify that middleware headers override next.config.js headers.
// We need to verify that middleware headers override next.config.js headers.
if (path === "/headers/override-from-middleware") {
responseHeaders.set("e2e-headers", "middleware");
return NextResponse.json({}, { headers: responseHeaders });
Expand Down
2 changes: 1 addition & 1 deletion examples-cloudflare/playground16/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"cf-typegen": "wrangler types --env-interface CloudflareEnv"
},
"dependencies": {
"next": "16.1.4",
"next": "16.2.1",
"react": "19.2.3",
"react-dom": "19.2.3"
},
Expand Down
4 changes: 0 additions & 4 deletions examples/app-router/open-next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export default {
},
},

dangerous: {
middlewareHeadersOverrideNextConfigHeaders: true,
},

imageOptimization: {
override: {
wrapper: "dummy",
Expand Down
2 changes: 1 addition & 1 deletion examples/app-router/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function proxy(request: NextRequest) {
// Response headers should show up in the client's response headers
responseHeaders.set("response-header", "response-header");

// For dangerous.middlewareHeadersOverrideNextConfigHeaders we need to verify that middleware headers override next.config.js headers.
// We need to verify that middleware headers override next.config.js headers.
if (path === "/headers/override-from-middleware") {
responseHeaders.set("e2e-headers", "middleware");
return NextResponse.json({}, { headers: responseHeaders });
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
"engines": {
"node": ">=24",
"pnpm": ">=10"
}
},
"packageManager": "pnpm@11.25.0"
}
3 changes: 3 additions & 0 deletions packages/aws/bin/open-next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

import "../dist/index.js";
5 changes: 3 additions & 2 deletions packages/aws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
"directory": "packages/open-next"
},
"bin": {
"open-next": "./dist/index.js"
"open-next": "./bin/open-next.js"
},
"files": [
"dist",
"bin",
"assets",
"README.md"
],
Expand Down Expand Up @@ -75,6 +76,6 @@
"typescript": "catalog:"
},
"peerDependencies": {
"next": "^16.0.10"
"next": "16.2.1"
}
}
3 changes: 3 additions & 0 deletions packages/cloudflare/bin/opennextjs-cloudflare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

import "../dist/cli/index.js";
7 changes: 4 additions & 3 deletions packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
"directory": "packages/cloudflare"
},
"bin": {
"opennextjs-cloudflare": "dist/cli/index.js"
"opennextjs-cloudflare": "bin/opennextjs-cloudflare.js"
},
"files": [
"README.md",
"bin",
"dist",
"templates"
],
Expand Down Expand Up @@ -72,14 +73,14 @@
"esbuild": "catalog:",
"globals": "catalog:",
"mock-fs": "catalog:",
"next": "catalog:",
"next": "catalog:aws",
"picomatch": "^4.0.2",
"rimraf": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:"
},
"peerDependencies": {
"next": "^16.0.10",
"next": "16.2.1",
"wrangler": "catalog:"
}
}
15 changes: 15 additions & 0 deletions packages/cloudflare/src/cli/utils/nextjs-support.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { describe, expect, test } from "vitest";

import { ensureNextjsVersionSupported } from "./nextjs-support.js";

describe("ensureNextjsVersionSupported", () => {
test("rejects versions without the routing-aware adapter contract", async () => {
await expect(ensureNextjsVersionSupported({ nextVersion: "16.2.0" })).rejects.toThrow(
"please upgrade to version 16.2.1 or greater"
);
});

test("accepts the version required by the adapter peer dependency", async () => {
await expect(ensureNextjsVersionSupported({ nextVersion: "16.2.1" })).resolves.toBeUndefined();
});
});
13 changes: 10 additions & 3 deletions packages/cloudflare/src/cli/utils/nextjs-support.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { compareSemver } from "@opennextjs/core/build/helper.js";
import logger from "@opennextjs/core/logger.js";

export async function ensureNextjsVersionSupported({ nextVersion }: { nextVersion: string }) {
if (compareSemver(nextVersion, "<", "14.2.0")) {
throw new Error("Next.js version unsupported, please upgrade to version 14.2 or greater.");
/**
* Verifies that Next.js and Wrangler support the adapter contract.
*
* @param options The installed Next.js version.
* @returns A promise that resolves when the versions are supported.
* @throws When Next.js predates the routing-aware adapter contract.
*/
export async function ensureNextjsVersionSupported({ nextVersion }: { nextVersion: string }): Promise<void> {
if (compareSemver(nextVersion, "<", "16.2.1")) {
throw new Error("Next.js version unsupported, please upgrade to version 16.2.1 or greater.");
}

const {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"vitest": "catalog:"
},
"peerDependencies": {
"next": "^16.0.10"
"@next/routing": "16.2.1",
"next": "16.2.1"
}
}
16 changes: 2 additions & 14 deletions packages/core/src/adapters/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ import path from "node:path";
import { debug } from "../logger";

import {
loadAppPathRoutesManifest,
loadAppPathsManifest,
loadAppPathsManifestKeys,
loadBuildId,
loadConfig,
loadConfigHeaders,
loadFunctionsConfigManifest,
loadHtmlPages,
loadMiddlewareManifest,
loadPagesManifest,
loadPrerenderManifest,
loadRoutesManifest,
loadRoutingConfig,
} from "./util.js";

export const NEXT_DIR = path.join(__dirname, ".next");
Expand All @@ -24,17 +19,10 @@ debug({ NEXT_DIR, OPEN_NEXT_DIR });

export const NextConfig = /* @__PURE__ */ loadConfig(NEXT_DIR);
export const BuildId = /* @__PURE__ */ loadBuildId(NEXT_DIR);
export const RoutingConfig = /* @__PURE__ */ loadRoutingConfig(NEXT_DIR);
export const HtmlPages = /* @__PURE__ */ loadHtmlPages(NEXT_DIR);
// export const PublicAssets = loadPublicAssets(OPEN_NEXT_DIR);
export const RoutesManifest = /* @__PURE__ */ loadRoutesManifest(NEXT_DIR);
export const ConfigHeaders = /* @__PURE__ */ loadConfigHeaders(NEXT_DIR);
export const PrerenderManifest = /* @__PURE__ */ loadPrerenderManifest(NEXT_DIR);
export const PagesManifest = /* @__PURE__ */ loadPagesManifest(NEXT_DIR);
export const AppPathsManifestKeys = /* @__PURE__ */ loadAppPathsManifestKeys(NEXT_DIR);
export const MiddlewareManifest = /* @__PURE__ */ loadMiddlewareManifest(NEXT_DIR);
export const AppPathsManifest = /* @__PURE__ */ loadAppPathsManifest(NEXT_DIR);
export const AppPathRoutesManifest = /* @__PURE__ */ loadAppPathRoutesManifest(NEXT_DIR);

export const FunctionsConfigManifest = /* @__PURE__ */ loadFunctionsConfigManifest(NEXT_DIR);

process.env.NEXT_BUILD_ID = BuildId;
Expand Down
Loading
Loading