vercel / next.js

The React Framework
https://nextjs.org
MIT License
123.38k stars 26.32k forks source link

assetPrefix with same name of route with catch-all segments won't work since 14.2 (Using Page Router) #65639

Open yanni-fe opened 2 months ago

yanni-fe commented 2 months ago

Link to the code that reproduces this issue

https://github.com/yanni-fe/nextjs-reproduce-demo

To Reproduce

  1. Create a next.js project
  2. Create a test route with catch-all segments
    pages
    |- demo
        |- [[...slug]].tsx
  3. add assetPrefix with same name of route
    // next.config.js
    const nextConfig = {
    assetPrefix: '/demo',
    }

open localhost:3000/demo will return 404

Current vs. Expected behavior

For versions before 14.2, it works well. After updating next.js to 14.2.3, it fails.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.5.0
Binaries:
  Node: 18.17
  npm: 9.8.1
  Yarn: 1.22.19
Relevant Packages:
  next: 14.2.3
  eslint-config-next: 14.2.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

Pages Router

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

next dev (local), next start (local)

Additional context

I think this is caused by this commit https://github.com/vercel/next.js/commit/4efe14238b5ab11935e73aa09631ef5ec8045b13

changes in packages/next/src/server/lib/router-utils/filesystem.ts at line 438

mantaspatsSurfShark commented 1 month ago

Either this should be fixed or documentation updated that you can't have same routes as assetPrefix