Janani
Janani

Reputation: 65

Why does Next.js 14 fail to resolve page route paths?

I'm encountering an issue with my Next.js project where I'm receiving the error message: "You cannot have two parallel pages that resolve to the same path." It specifically references /(landing)/page and /(main)/(routes)/(documents)/page. I've checked the route group documentation provided by Next.js, but I'm still unclear on how to resolve this issue effectively. Could you please provide guidance on how to address this error and ensure proper routing in my Next.js application?

enter image description here

I attempted to define routes in Next.js 14 but encountered unresolved paths for pages. I expected the routes to map correctly to their respective pages, but actual results showed unresolved paths.

Upvotes: 1

Views: 3228

Answers (1)

Youssouf Oumar
Youssouf Oumar

Reputation: 46171

Since route groups, aka the folders with (...) are not taken into consideration when resolving path, app/(landing)/page.js and app/(main)/(routes)/(documents)/page.js will match / as it's like you had tow app/page.js, creating a conflict.

So you have to decide which one should render when / is requested. If it's app/(landing)/page.js, you should change app/(main)/(routes)/(documents)/page.js to something like app/(main)/(routes)/(documents)/about/page.js, so it matches /about.

Upvotes: 1

Related Questions