Since I've updated from 1.8.0-1 to 1.9.1, some links to dynamic routes show a weird behavior. At first they log the following error to the console ...
... and then they redirect to the page successfully. Refreshing the page works fine, too, so the issue is most likely related to the link component, not any routes setup.
Here's the folder structure:
pages
products
[slug].page.tsx
routes.json inside the products folder:
{
"/": {
"de": "produkte"
}
}
The link looks like this:
<Link href={`/products/${product.slug}`}>...</Link>
The debug-mode logs the following object when clicking the link:
Workaround
After some experimenting, I've found a solution which seems to work. If I built the link like this, the 404 doesn't show up any more:
<Link href={{ pathname: "/products/[slug]", query: { slug: product.slug }}}>...</Link>
The debugged objects looks a bit different then:
Am I missing something, or is my workaround maybe even the intended way of using links to dynamic routes?
However, the initially described code worked perfectly fine before the update.
Strange, there are some tests checking if both syntax work... :thinking:
This is a bug, but yes, your workaround is a correct syntax: I even only use this one.
Since I've updated from 1.8.0-1 to 1.9.1, some links to dynamic routes show a weird behavior. At first they log the following error to the console ... ... and then they redirect to the page successfully. Refreshing the page works fine, too, so the issue is most likely related to the link component, not any routes setup.
Here's the folder structure:
routes.json inside the products folder:
The link looks like this:
<Link href={`/products/${product.slug}`}>...</Link>
The debug-mode logs the following object when clicking the link:
Workaround After some experimenting, I've found a solution which seems to work. If I built the link like this, the 404 doesn't show up any more:
<Link href={{ pathname: "/products/[slug]", query: { slug: product.slug }}}>...</Link>
The debugged objects looks a bit different then:
Am I missing something, or is my workaround maybe even the intended way of using links to dynamic routes? However, the initially described code worked perfectly fine before the update.