-
Notifications
You must be signed in to change notification settings - Fork 67
You cannot define a route with the same specificity as a optional catch-all route #76
Comments
Hi @afzalsayed96, Welcome to next-on-netlify! 👋 Thanks for the detailed error description and page structure. The error you receive is intentional: You have an index route If you want the index route to render on requests for If you want the optional catch all route to render on requests for Does this help? Please let us know if you have any doubts at all and I'm more than happy to expand on this further! 😊 |
Hey @FinnWoelm, I do not have an index page explicitly defined. My pages directory looks like this.
Instead
Similarly I need Also note that there's no error on |
hey @afzalsayed96 i hate to ask but can you open a repro repo for us 🙏 |
https://github.com/afzalsayed96/netlify-nextjs-repro Also here's full error log:
I realized that this happens only when |
Hi @afzalsayed96, Thank you for creating this repo for reproducing the issue! That was fantastic and extremely helpful. I'm happy to report that @lindsaylevine and I have identified the issue. It's indeed a bug in The issue is related to the way in which we sort the redirects that [
{
route: '/',
target: '/.netlify/functions/next_rest',
force: true,
conditions: [ 'Cookie=__prerender_bypass,__next_preview_data' ]
},
{
route: '/_next/data/xvcNJopdBjVWAhGZJIQ9K/index.json',
target: '/.netlify/functions/next_rest',
force: true,
conditions: [ 'Cookie=__prerender_bypass,__next_preview_data' ]
},
{
route: '/careers',
target: '/.netlify/functions/next_rest',
force: true,
conditions: [ 'Cookie=__prerender_bypass,__next_preview_data' ]
},
{
route: '/_next/data/xvcNJopdBjVWAhGZJIQ9K/careers.json',
target: '/.netlify/functions/next_rest',
force: true,
conditions: [ 'Cookie=__prerender_bypass,__next_preview_data' ]
},
{ route: '/[[...rest]]', target: '/.netlify/functions/next_rest' },
{
route: '/_next/data/xvcNJopdBjVWAhGZJIQ9K/[[...rest]].json',
target: '/.netlify/functions/next_rest'
}
] We use a Next.js-internal sorting function to ensure that our redirects are put in the right order (more specific, static routes must come before more generic, dynamic routes). For example, the redirect for /careers must precede the redirect for //[[...rest]]. It turns out that with the redirects that we add to support Next.js preview mode, we have a few edge cases where the Next.js-internal sorting function unintentionally reports an error, even though there is none. That's not a mistake on Next.js' side: the Next.js function was not intended to sort redirects like ours; we have just been "misusing" it because it worked well — until now :) We will fix this by returning our sorting strategy back to what we had back in the day, where we let Next.js sort only our dynamic redirects (e.g., next-on-netlify/lib/setupRedirects.js Line 18 in cef50d0
With the holidays around the corner, we'll probably need a bit to get this fixed (early next year?!). We will also add a regression test for this scenario, to make sure that it does not happen again in the future! We will keep you posted! Thank you again @afzalsayed96 😊 |
hey @afzalsayed96 ! just merged the sorting work and confirmed NoN runs on the repo you provided :) will release shortly |
I have the following page structure:
Command
build
runs successfully but runningnext-on-netlify
spits out the following error:The text was updated successfully, but these errors were encountered: