Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Hard Navigation In Pages Router Dev Mode When Custom assetPrefix is Applied #77241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mgreenw opened this issue Mar 18, 2025 · 0 comments
Open
Labels
linear: next Confirmed issue that is tracked by the Next.js team. Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. Pages Router Related to Pages Router.

Comments

@mgreenw
Copy link

mgreenw commented Mar 18, 2025

Link to the code that reproduces this issue

https://github.com/mgreenw/next-pages-router-asset-prefix-hard-nav-repro

To Reproduce

  1. Load the reproduction repo + follow setup instructions
  2. Click the link to "Page 2". Notice the hard browser navigation.

Current vs. Expected behavior

Current:

  • Pages router in dev mode with custom assetPrefix applied
  • Clicking a link to a new pages causes a hard navigation.
    • First there is a request to the JS file for the page, e.g. /custom-asset-prefix/_next/static/chunks/pages/page2.js. This request results in a 404
    • A hard navigation is performed
    • The page loads correctly after the hard navigation
  • Sometimes a soft navigation happens on subsequent clicks (maybe if the cache is warm?)

Image

Expected:

  • Soft navigation is always performed in dev mode when an asset prefix is applied

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 20.14.0
  npm: 10.7.0
  Yarn: 1.22.19
  pnpm: 9.7.0
Relevant Packages:
  next: 15.2.3 // Latest available version is detected (15.2.3).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Linking and Navigating

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Related issue:#63623
App Router-only fix: #63627

This seems to be a Webpack-only issue. I wasn't able to repro with Turbopack.

@github-actions github-actions bot added the Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. label Mar 18, 2025
@samcx samcx added the Pages Router Related to Pages Router. label Mar 19, 2025
@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear: next Confirmed issue that is tracked by the Next.js team. Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. Pages Router Related to Pages Router.
Projects
None yet
Development

No branches or pull requests

2 participants