-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Describe the bug
Before further ado, here’s a comparison between a /api/user/{id} request which fetches /api/auth/session through the network even on the server side, versus a /api/site/{id} call, which isn’t protected via getSession. Unfortunately, there’s a quite large margin between response times.
Steps to reproduce
Call getSession on the server side and observe that it makes an HTTP request instead of just calling functions locally.
Expected behavior
Calls to getSession should be executed locally in a server environment. A separate getServerSession method could be added as a non-isomorphic solution without any HTTP calls.
Additional context
According to the official Next.js docs:
You should not use
fetch()to call an API route ingetServerSideProps. Instead, directly import the logic used inside your API route. You may need to slightly refactor your code for this approach.Fetching from an external API is fine!
This seems to hurt performance badly.
Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
- Found the documentation helpful
- Found documentation but was incomplete
- Could not find relevant documentation
- Found the example project helpful
- Did not find the example project helpful
Thank you for maintaining this wonderful library – it really helps a lot! 🙏
