vercel / vercel/next.js

Symlinked app pages fail to resolve in DEV but not PRODUCTION

Open
#53,175 11 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Linking and Navigating
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Verify canary release
  • I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
    Binaries:
      Node: 18.12.1
      npm: 9.7.1
      Yarn: 1.22.18
      pnpm: 8.6.6
    Relevant Packages:
      next: 13.4.13-canary.1
      eslint-config-next: 13.4.12
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)

App Router, Routing (next/router, next/navigation, next/link), SWC transpilation

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

https://github.com/cseitz/next-13.4.13-bug-symlinked-app-dir/

To Reproduce

Running next dev and visiting localhost:3000/test1 will 404 NOT FOUND.

However, running next build and next start and visiting localhost:3000/test1 will work just fine.

(Additional details in the README of my repo)

Describe the Bug

I am using a symlinked directory within my app folder. This symlink route 404's in development, but works perfectly in production.

  • I have a directory, src/features/test1/app, that is symlinked into src/app/(features)/(test1)
  • I symlinked this folder via ln -sr "./src/features/test1/app" "./src/app/(features)/(test1)"
  • Running next dev and visiting localhost:3000/test1 will 404 NOT FOUND
Expected Behavior

When running via next dev:

  • Visiting localhost:3000/test1 should render src/features/test1/app/test1/page.tsx, which is located within the symlinked folder
  • That next dev mirrors the behavior of next build && next start (which is proven to support this symlink feature as it works in production)
Which browser are you using? (if relevant)

Chrome 114.0.5735.199

How are you deploying your application? (if relevant)

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and its README, then run next dev against /test1 and compare it with next build followed by next start. Trace how the symlinked src/app/(features)/(test1) directory resolves to src/features/test1/app/test1/page.tsx; done means development renders /test1 like production without breaking ordinary App Router routes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react
Domain
devtools, frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.