Skip to content

useSession() hook returning undefined in NextJS v13.4.3 #7845

Answered by Cartrogen
Cartrogen asked this question in Help
Discussion options

You must be logged in to vote

Hi @Byron0000 and @KrishnaCodez,

So I solved my entire auth problem by doing it on the backend. Basically I used passportjs in my backend nestjs repository to issue a JWT. I then pass this JWT to the frontend as an HTTPONLY cookie which get stored in the browser. This JWT is then passed over to the backend from the frontend with every endpoint call and I created an auth guard (again with passportjs) which extracts the JWT verifies it and either allow the user through or kick them out and the frontend redirects them to login page.

Now the only issue with this is that if you want to implement a feature such that your frontend does not make a call if a JWT does not exist or is expirted, you …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Cartrogen
Comment options

@Byron0000
Comment options

@iurvish
Comment options

@Cartrogen
Comment options

Answer selected by Cartrogen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
question Ask how to do something or how something works
4 participants
Converted from issue

This discussion was converted from issue #7839 on June 20, 2023 14:24.