Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getServerSideProps in dynamic Route override other page getServerSideProps #42986

Open
1 task done
matteo-naif opened this issue Nov 16, 2022 · 2 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.

Comments

@matteo-naif
Copy link

Verify canary release

  • 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
@matteo-naif matteo-naif added the bug Issue was opened via the bug report template. label Nov 16, 2022
@matteo-naif
Copy link
Author

  1. I run the project with the command "NODE_OPTIONS='--inspect' next dev"
    Schermata 2022-11-21 alle 09 20 36

  2. I open the project in index page and the getServerSideProps of [slug] page run as well
    Schermata 2022-11-21 alle 09 21 26

  3. As you can see in index page there is not getServerSideProps
    Schermata 2022-11-21 alle 09 21 35

  4. But in [slug] . IMPORTANT : the context param is not working as well
    Schermata 2022-11-21 alle 09 21 46

  5. In about page there is another function of getServerSideProps
    Schermata 2022-11-21 alle 09 21 55

  6. But if I visit it always run the [slug] one
    Schermata 2022-11-21 alle 09 22 08

Someone with the same problem?

@vercel-release-bot
Copy link
Collaborator

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

@vercel-release-bot vercel-release-bot added the stale The issue has not seen recent activity. label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.
Projects
None yet
Development

No branches or pull requests

2 participants