vercel / next.js

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

`afterFiles` rewrite with a host rule doesn't works #52225

Open lu-zen opened 1 year ago

lu-zen commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP PREEMPT_DYNAMIC Thu, 30 Mar 2023 14:10:04 +0000
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: 1.22.19
      pnpm: 8.6.4
    Relevant Packages:
      next: 13.4.9-canary.1
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 4.9.5
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), Routing (next/router, next/navigation, next/link)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/lu-zen/nextjs-rewrite-afterfiles-bug

To Reproduce

  1. run the project
  2. navigate to the root path using localhost (localhost:3000)

Describe the Bug

It render the root page content instead of the rewritten one that's configured on next.config.js

Expected Behavior

Since there's a afterFiles rewrite in effect for the host localhost it should rewrite and render the page inside the rewritten path instead. It works fine if the rewrite is defined as a "beforeFile" one.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

lu-zen commented 1 year ago

Ps.: Even without the host rule it doesn't work either.