Is this a good workaround checking auth? #67111
Unanswered
ghyath5
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As we are facing issues having DB calls inside middleware I've ended up checking the session in this way and I would like to know is this a solid/good way to implement session check!
I ended up having structured folders (guest) (protected)
with layouts inside them
And moved auth check to these layouts
in layout.tsx inside (protected) folder I have my auth check function if no valid session just redirects to the login page.
in (guest) folder layout.tsx checks if there is a valid session it redirects to /dashboard or whatever the page is.
Put all protected page inside (protected) folder
Do I miss anything in this implementation?
Does this way good in terms of performance?
Is there anyway to pass user session down to the protected pages to avoid calling auth() function on every page needs it?
Beta Was this translation helpful? Give feedback.
All reactions