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

getSession() doesn't work on server side when request is POST #7191

Closed
clueleaf opened this issue Apr 8, 2023 · 3 comments
Closed

getSession() doesn't work on server side when request is POST #7191

clueleaf opened this issue Apr 8, 2023 · 3 comments
Labels
docs Relates to documentation triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@clueleaf
Copy link

clueleaf commented Apr 8, 2023

What is the improvement or update you wish to see?

Since I faced a situation where getSession() doesn't work properly on the server side, I think this part of doc should be fixed.

On the server side, **this is still available to use**, however, we recommend using `getServerSession` going forward. The idea behind this is to avoid an additional unnecessary `fetch` call on the server side. For more information, please check out [this issue](https://github.com/nextauthjs/next-auth/issues/1535).

Is there any context that might help us understand?

When using getSession() on the server side with POST request, it returns null as described here.
#7167

Does the docs page already exist? Please link to it.

On the server side, **this is still available to use**, however, we recommend using `getServerSession` going forward. The idea behind this is to avoid an additional unnecessary `fetch` call on the server side. For more information, please check out [this issue](https://github.com/nextauthjs/next-auth/issues/1535).

@clueleaf clueleaf added docs Relates to documentation triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Apr 8, 2023
@naokato
Copy link

naokato commented Apr 11, 2023

If possible, I would like to continue using useSession on the server side.
I have already used it in many places, and for now, the overhead of making fetch requests each time is not a big concern for me.

@balazsorban44
Copy link
Member

We will deprecate/stop recommending getSession server-side, as it is inefficient and can cause issues/misunderstandings. You should always use getServerSession instead.

@clueleaf
Copy link
Author

@balazsorban44
I understand we should use getServerSession on the server side, but this issue is about documentation.
Because getSession doesn't work at all in some cases, I think the document should not be On the server side, **this is still available to use**.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Relates to documentation 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