We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The title says it all..
I am trying to use getSession({ req }) on the server side and it's taking way too long.
getSession({ req })
Why is it taking so long? I didn't flag it as bug since I might have overlooked something.
I've hit this test API on the client side (latest Chrome and Safari) using axios and also using Postman (no cookies were passed).
test
The result is that it regularly takes 4-8 seconds to complete.
This delay is only present when deployed onto Vercel. When running locally (using vercel dev) there is no delay and everything is alright.
vercel dev
For reference, here is the test API on my sample deployment (hit this in Postman with a GET request): https://gbs-website-aybet3xkf-eagle-logistics.vercel.app/api/test
The session in the response is expectedly null.
Here are the relevant files:
pages/api/auth/[...nextauth].ts
import NextAuth, { NextAuthOptions } from 'next-auth'; import Providers from 'next-auth/providers'; const authOptions: NextAuthOptions = { providers: [ Providers.Credentials({ credentials: { username: { label: "Username", type: "text", placeholder: "jsmith" }, password: { label: "Password", type: "password" } }, async authorize(credentials, req) { return null; } }), ] }; export default NextAuth(authOptions);
pages/api/test.ts
import type { NextApiRequest, NextApiResponse } from 'next'; import { getSession } from 'next-auth/client'; export default async (req: NextApiRequest, res: NextApiResponse) => { console.log('session load start:', new Date().toISOString()); const session = await getSession({ req }); console.log('session load end:', new Date().toISOString()); res.status(200).json({ session }); }
The text was updated successfully, but these errors were encountered:
Duplicate of #1535
Sorry, something went wrong.
No branches or pull requests
Question 馃挰
The title says it all..
I am trying to use
getSession({ req })
on the server side and it's taking way too long.Why is it taking so long? I didn't flag it as bug since I might have overlooked something.
Other info
I've hit this
test
API on the client side (latest Chrome and Safari) using axios and also using Postman (no cookies were passed).The result is that it regularly takes 4-8 seconds to complete.
This delay is only present when deployed onto Vercel. When running locally (using
vercel dev
) there is no delay and everything is alright.For reference, here is the
test
API on my sample deployment (hit this in Postman with a GET request):https://gbs-website-aybet3xkf-eagle-logistics.vercel.app/api/test
Image for reference:
The session in the response is expectedly null.
Version: 3.29.0
How to reproduce 鈽曪笍
Here are the relevant files:
pages/api/auth/[...nextauth].ts
pages/api/test.ts
The text was updated successfully, but these errors were encountered: