You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently started learning NextAuth and I have three questions:
Why does the session token only show in the browser and not Postman when I use the default signin and return a static user object?
How do I setup Postman to work so that it doesn't skip the authorize function and callbacks?
Why are my req and res objects undefined?
next-auth.session-token (only shows on browser)
next-auth.csrf-token (shows up on both browser and Postman)
next-auth.callback-url (shows up on both browser and Postman)
import NextAuth from 'next-auth';
import Providers from 'next-auth/providers';
const options = {
session: {
jwt: true,
maxAge: 60 * 60,
},
callbacks: {
async signIn(user, account, profile, req, res) {
console.log('SIGNIN: ', user, account, profile, req, res);
return true;
},
async redirect(url, baseUrl, req, res) {
console.log('REDIRECT: ', url, baseUrl, req, res);
return baseUrl;
},
async session(session, user, req, res) {
console.log('SESSION: ', session, user, req, res);
return session;
},
async jwt(token, user, account, profile, isNewUser, req, res) {
console.log('JWT: ', token, account, req, res);
return token;
},
},
providers: [
Providers.Credentials({
credentials: {
email: { label: 'email', type: 'email', placeholder: 'jdoe@email.com' },
password: { label: 'password', type: 'password' },
},
async authorize(credentials, req) {
**ENTERS HERE AND THEN CALLBACKS WHEN I SIGNIN ON LOCALHOST:PORT/API/AUTH/SIGNIN USING CHROME**
**HOWEVER, DOES NOT ENTER HERE OR CALLBACKS USING POSTMAN**
console.log('IN NEXT AUTH!!!');
console.log(credentials, req);
**REQ SHOWS UP AS UNDEFINED, SAME FOR REQ AND RES IN CALLBACKS**
return {user: 'User'}
},
}),
],
};
export default (req, res) => NextAuth(req, res, options)
-- Please see the text in bold and caps above. Sorry if the issue is trivial but I don't know if I'm missing something...
The text was updated successfully, but these errors were encountered:
I recently started learning NextAuth and I have three questions:
Why does the session token only show in the browser and not Postman when I use the default signin and return a static user object?
How do I setup Postman to work so that it doesn't skip the authorize function and callbacks?
Why are my req and res objects undefined?
next-auth.session-token (only shows on browser)
next-auth.csrf-token (shows up on both browser and Postman)
next-auth.callback-url (shows up on both browser and Postman)
-- Please see the text in bold and caps above. Sorry if the issue is trivial but I don't know if I'm missing something...
The text was updated successfully, but these errors were encountered: