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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal API fetch with getServerSideProps - getSession() in SSR #4741

Closed
younes-alouani opened this issue Jun 21, 2022 · 3 comments
Closed
Labels
enhancement New feature or request triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@younes-alouani
Copy link

younes-alouani commented Jun 21, 2022

Description 馃摀

According to the Next Auth documentation.
For a page using SSR, I need to use getSession() to get the session.
This causes your internal API (/api/auth/session) to be called. Why are we making a request from the server to the server itself, isn't this unnecessary?
This is an unnecessary, inefficient and expensive approach, as it will result in an additional request due to the execution of getServerSideProps and API Routes on the server.
I propose that we create an additional function suitable for SSR mode only.

How to reproduce 鈽曪笍

export default function Page({ prop1, prop2, prop3 }) {
        // render etc.
}

export async function getServerSideProps(context) {
const session = await getSession(context)
// etc. 

Contributing 馃檶馃徑

No, I am afraid I cannot help regarding this

@younes-alouani younes-alouani added enhancement New feature or request triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Jun 21, 2022
@younes-alouani younes-alouani changed the title Interact with sessions during Server Side rendering Internal API fetch with getServerSideProps - getSession() in SSR Jun 21, 2022
@balazsorban44
Copy link
Member

This is known, thanks. #4116 The API is not final (we might iterate on it, hence the unstable_ name), but the idea is the same. 馃憤

@younes-alouani
Copy link
Author

Thank you for the response 鈽猴笍

@ajsharp
Copy link

ajsharp commented Jun 27, 2022

The API docs are out of date here, as they still suggest the unstable_getServerSession function name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

3 participants