-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Multiple Optional Catchall Routes with overlapping patterns fails to correctly fall-back in dev mode #17367
Comments
The bug you're describing is the expected behavior, and there's no fallback behavior on routes. Because dynamic routes have precedence over catch all routes, |
@lfades Thanks for taking a look at this issue! If the expected behavior is as described
The we are not experiencing this behavior, and we are seeing inconsistency in how Next.js behaves. Running
And during build, we see Which is both not following the behavior described, and also inconsistent. I think this is still an issue worth addressing |
@brandondc741 I'm not sure I follow, during build the 404 page is only generated once. |
@lfades Following the repro steps provided will make the issue clear: Here is a video of the behavior. |
Hey, I am new to open source. Can I try to work on this issue? |
@fakeharahman I haven't done any work investigating this one yet, so go ahead and take a look! |
I'm experiencing a similar issue. I have the following structure pages/foo/[...slug].tsx In the catchAllRoute of [[...slug]].tsx in the root, there exists a page foo/xy that is not covered by the filter in We managed to identify the possible cause of this bug: A fix of this bug should consider the overlapping catchAllRoutes based on their filter in |
I have the same issue:
will always call the first route in dev mode, no matter what the URL is. In Next 12, this also doesn't work:
|
@apfelbox (@bits-by-brandon) Try this:
Should result in:
UPDATE: So, in addition to the above ^^^ you can do either of these:
or
See https://nextjs.org/docs/pages/api-reference/next-config-js/rewrites for more info. |
Bug report
Describe the bug
While next is in dev mode, it fails to build appropriate catchall route when multiple catchalls exist with overlapping patterns. For example, a page at
pages/[[...foo]].js/
will not be built ifpages/[bar]/[[...bazz.js]]
exists, until first navigating to the homepage/
to force a build of[[...foo]]
To Reproduce
Created an example branch with this behavior
https://github.com/brandondc741/next-catchall-route-bug
Repro steps are located in https://github.com/brandondc741/next-catchall-route-bug/blob/master/HOW_TO_REPLICATE_ISSUE.md
npx next dev
Expected behavior
In dev mode, when next.js is given the path
/foo/root
it shouldpages/[firstSegment]/[[...nestedSlug]].js
[[...slug]].js
System information
The text was updated successfully, but these errors were encountered: