NextJS 16, details page running infinitely #205452
Replies: 2 comments 3 replies
|
There are three separate problems here, and the one causing the hang is not the one you are looking at. 1. The param name does not match the folderYour route is interface Props {
params: Promise<{ id: string }>; // ← there is no `id`
}
const { id } = await params; // ← undefinedIn the App Router the key on interface Props {
params: Promise<{ itemId: string }>;
}
const { itemId } = await params;2. The URL is not valid JavaScript`${process.env.NEXT_PUBLIC_API_URL/list/itemId=${id}`The closing brace of the first expression is missing. As written, the interpolation contains `${process.env.NEXT_PUBLIC_API_URL}/list?itemId=${itemId}`Note the And the fetch({`...`}, { next: { revalidate: 60 } })
// ^ an object, not a URLIt takes the string directly: fetch(`...`, { next: { revalidate: 60 } })3.
|
|
The issue is most likely that your server component is fetching from the same Next.js app. If |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Question
Body
I am having an issue with a details page.
Structure:
On the list page there is a link to the details page:
<Link href={`${process.env.NEXT_PUBLIC_API_URL/list/itemId=${id}`}>Item details</Link>The details page:
Chrome shows a 200 ok response. However, there is also a headers error, 'UND_ERR_HEADERS_TIMEOUT'
Guidelines
All reactions