最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论