getServerSideProps in dynamic Route override other page getServerSideProps
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000
Binaries:
Node: 14.19.3
npm: 6.14.17
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.3
eslint-config-next: 13.0.3
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome 107.0.5304.110
How are you deploying your application? (if relevant)
No response
Describe the Bug
When I work on my project using next dev seems to work properly all the getServerSideProps functions but if I want to debug the server side using the command NODE_OPTIONS='--inspect' next dev the console show me that it run only the getServerSideProps function of the dynamic route.
It happens also with a fresh project, I report the page folder structure: -- pages -- -- _app.tsx -- -- [slug].tsx -- -- index.tsx
If there is a serverSideProps in index.tsx and one in [slug].tsx the second one override the one of the page visited.
It happens with Next v13 but I detected the same problem also with the v12.
Expected Behavior
Visiting the page index I want that the correct getServerSideProps function runs.
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://stackblitz.com/edit/vercel-next-js-euqh9s?file=pages/[slug].tsx
To Reproduce
- Create a new page with dynamic route (example: [slug].tsx).
- Add a getServerSideProps functions
- Run project using the command
NODE_OPTIONS='--inspect' next dev - Visit the homepage in localhost:3000
- in console open the dev tool clicking on the green node icon
- in the console should show the console.log and messages from backend
- If I visit the index page I see the result of the getServerSideProps function from the [slug].page