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/fluffy-penguins-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

fix: Ensure dynamic routes are excluded in getStaticAPIRoutes
12 changes: 12 additions & 0 deletions examples/app-router/app/api/auth/[...better-auth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NextResponse } from "next/server";

export async function GET(
_req: Request,
{ params }: { params: Promise<{ "better-auth": string[] }> },
) {
const { "better-auth": slugs } = await params;

return NextResponse.json({
slugs,
});
}
4 changes: 2 additions & 2 deletions packages/open-next/src/core/routing/routeMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ function getStaticAPIRoutes(): RouteDefinition[] {
const appPathsStaticAPIRoutes = Object.values(AppPathRoutesManifest)
.filter(
(route) =>
route.startsWith("/api/") ||
(route === "/api" && !dynamicRoutePages.has(route)),
(route.startsWith("/api/") || route === "/api") &&
!dynamicRoutePages.has(route),
)
.map(createRouteDefinition);

Expand Down
10 changes: 10 additions & 0 deletions packages/tests-e2e/tests/appRouter/dynamic.catch-all.hypen.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from "@playwright/test";

// https://github.com/opennextjs/opennextjs-cloudflare/issues/942
test("Dynamic catch-all API route with hyphen param", async ({ request }) => {
const res = await request.get("/api/auth/opennext/is/really/cool");
expect(res.status()).toBe(200);
expect(res.headers()["content-type"]).toBe("application/json");
const json = await res.json();
expect(json).toStrictEqual({ slugs: ["opennext", "is", "really", "cool"] });
});
Loading