Skip to content

fix: populate static API routes for our staticRouteMatcher #875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sommeeeer
Copy link
Contributor

@sommeeeer sommeeeer commented May 23, 2025

Next filters out all static routes that starts with /api on this line from routes-manifest.json.

This makes both static API routes from page router and app router (including page.tsx in /api/* on app router) not get caught by our staticRouteMatcher cause it relies on routes-manifest.json to have those routes. If you had a catch-all route at the root (i.e: /[[...catch-all]].tsx) with fallback: false it would break all API routes cause handleFallbackFalse in routingHandler would return a 404. In this PR we include those routes and can also get rid of isApiRoute in routingHandler. As it wont be needed anymore.

I added an E2E to app-pages-router to showcase this. Without the fix in this PR the tests-e2e/tests/appPagesRouter/api.test.ts would fail, and possibly more. As we would get a 404 instead.

Reference for the Discord thread

Copy link

changeset-bot bot commented May 23, 2025

🦋 Changeset detected

Latest commit: 229f62f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch
app-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented May 23, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/aws@875

commit: 229f62f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant