最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Next.js 15 dynamic routing fails for nested routes, like [endpoint][entry] - Stack Overflow

matteradmin9PV0评论

I add a dynamic route as following images illustrates

The page.tsx in [endpoint] folder is


type Props = {
  params: Promise<{ endpoint: string}>
}

const page = async ({params}: Props) => {
  const {endpoint} = await params;
  return (
    <div>{endpoint}</div>
  )
}

export default page;

The page.tsx in [entry] folder is

export default async function Page({
  params
}: {
  params: Promise<{ endpoint: string; entry: string }>
}) {
  const {endpoint, entry} = await params;
  return <h1>{endpoint}{entry}</h1>
}

Then I test the following route

http://localhost:3000/aaa, the page renders as expected.

However, the page always shows 404 when I test http://localhost:3000/aaa/bbb

Does anyone can give me a hand to address this issue?

I add a dynamic route as following images illustrates

The page.tsx in [endpoint] folder is


type Props = {
  params: Promise<{ endpoint: string}>
}

const page = async ({params}: Props) => {
  const {endpoint} = await params;
  return (
    <div>{endpoint}</div>
  )
}

export default page;

The page.tsx in [entry] folder is

export default async function Page({
  params
}: {
  params: Promise<{ endpoint: string; entry: string }>
}) {
  const {endpoint, entry} = await params;
  return <h1>{endpoint}{entry}</h1>
}

Then I test the following route

http://localhost:3000/aaa, the page renders as expected.

However, the page always shows 404 when I test http://localhost:3000/aaa/bbb

Does anyone can give me a hand to address this issue?

Share Improve this question asked Nov 18, 2024 at 10:25 Ryan XuRyan Xu 191 silver badge5 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

You have one extra space before the dot in filename [endpoint]/[entry]/page .tsx

I finally addressed this issue by downgrading Next.js from 15 to 14. It seems Next.js 15 is not very robust.

Post a comment

comment list (0)

  1. No comments so far