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

I add a dynamic route as following images illustratesThe page.tsx in [endpoint] folder istype Props = {

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745626224a4636821.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信