0
votes

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:

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?

1

1 Answers

0
votes

It turns out this was happening because of dummy placeholder links on the page: <Link href="#"><a>Home</a></Link>. Replacing them with working links solved the problem.