Dynamic routes via symlinks are broken across multiple Next.js versions.
Dynamic routes accessed through symlinks return 404 errors, while static routes work fine. The issue persists across multiple Next.js versions and requires investigation into how symlinks are handled in the routing system. A potential fix exists in a PR, but it's unclear if it fully resolves the issue.
Dynamic Routes in symlinks is not working
I don't think github repos support symlink commits so this is how you can reproduce this:
In project folder:
mkdir pages/nolink
echo "export default function Post() {return <div>Works</div>}" > "pages/nolink/[id].js"
echo "export default function index() {return <div>Works</div>}" > "pages/nolink/index.js"
ln -s nolink pages/symlinktest
I also tried this in next.config.js:
module.exports = {
webpack: (config, { buildId, dev }) => {
config.resolve.symlinks = false
return config
},
}
index.js is for debug the error. Removing index.js did not help. This points to Dynamic Routes not supporting symlinks.
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!