To use dynamic routes I have created a pages/[slug].js
page and I link to it as recommended:
<Link href="/shop/[slug]" as={`/shop/${item.slug}`}>
<a>{item.title}</a>
</Link>
I have followed the Next.js documentation:
- https://nextjs.org/docs/routing/dynamic-routes
- https://nextjs.org/docs/api-reference/next/link#dynamic-routes
The link and the page work as expected locally after running next dev
, however in production (or after building the app and running next start
locally), after navigating to the dynamic route, a non-existent script is systematically loaded. It doesn't crash the app but it does generate a request with a 404 status code.
The script is loaded from /_next/static/___/pages/shop/example-page.js
.
What could be the cause?