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

Change to use NextAuth.js getServerSession #11

Closed
trentprynn opened this issue Oct 8, 2021 · 0 comments
Closed

Change to use NextAuth.js getServerSession #11

trentprynn opened this issue Oct 8, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@trentprynn
Copy link
Owner

Currently our Next.js app uses server side rendering on almost all pages. It does a lot of await getSession(context) calls to verify the user is signed in before fetching data and showing them the page. Additionally in a lot of our API routes we make the same call to get the session to verify the user has access to whatever resource they're calling for.

The implementation for that method currently uses fetch and therefore http under the hood. Because we're running the app serverless on Vercel's platform this is extremely slow and makes the entire app feel sluggish.

The library is aiming to support a getServerSession method in v4 (which we're already on the beta version of) which should allow us to follow the recommended practice of not making fetch calls from a server side route.

Below is a quote from the next documentation about this

Note: You should not use fetch() to call an API route in getServerSideProps. Instead, directly import the logic used inside your API route. You may need to slightly refactor your code for this approach.

Reference comment about this new method coming down the pipeline:
nextauthjs/next-auth#1535 (comment)

@trentprynn trentprynn added the enhancement New feature or request label Oct 8, 2021
@trentprynn trentprynn self-assigned this Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant