title: NextAuth authorizes user but user info is null
body: <p>I am trying to implement NextAuth with Credentials (email and password). <br>
  I have set up my mongodb for this. I also set up <code>/api/proile/</code> route to post login credentials and tested it out with Postman, returns user correctly. <br></p>
  <p><br> But the problem starts with after logging in. when I log in, credentials return in the vscode terminal (I console log in <code>/api/auth/[...nextauth].js</code> with <code>console.log(credentials)</code> but in the browser it authorizes the user, i can access and view protected routes and stuff, but when I log the session in front-end, it displays as <code>null</code> for user information as you can see in the picture below; <br>
  <a href="https://i.stack.imgur.com/XxNyh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XxNyh.png" alt="consolelog1" /></a></p>
  <p>here is my <code>/api/auth/[...nextauth].js</code> code; <br></p>
  <pre><code>import NextAuth from 'next-auth';
  import Providers from 'next-auth/providers';
  import { connectToDatabase } from '../../../util/mongodb';
  
  const options = {
    providers: [
   
      Providers.Credentials({
        name: 'Credentials',
        credentials: {
          email: { label: 'Email', type: 'text' },
          password: { label: 'Password', type: 'password' },
        },
        async authorize(credentials, req) {
          console.log(credentials);
          const res = await fetch('http://localhost:3000/api/profile/', {
            method: 'POST',
            body: JSON.stringify(credentials),
            headers: {
              'Content-Type': 'application/json',
            },
          });
          const user = await res.json();
  
          // const user = { id: '1', name: 'Suat Bayrak', email: 'test@test.com2' };
  
          if (user) {
            return user;
          } else {
            return null;
          }
        },
      }),
    ],
    pages: {
      signIn: '/signin',
    },
    session: {
      jwt: true,
      maxAge: 30 * 24 * 60 * 60,
      updateAge: 24 * 60 * 60,
    },
  
  
    database:             `mongodb+srv://${process.env.MONGO_DB_USERNAME}:${process.env.MONGO_DB_PASSWORD}@nextjs-academia-    sb.ki5vd.mongodb.net/test`,
  };
  
  export default (req, res) =&gt; NextAuth(req, res, options);
  </code></pre>
  <p>by the way, when I use static user credentials like i commented in the code above, it works perfectly fine and returns session info correctly... <br> <br>
  Also here is my <code>/pages/signin.js</code></p>
  <pre><code>import { signIn } from 'next-auth/client';
  import { useState } from 'react';
  import { useRouter } from 'next/router';
  
  export default function SignIn() {
    const router = useRouter();
  
    const [email, setEmail] = useState('');
    const [password, setPassword] = useState('');
    const [loginError, setLoginError] = useState('');
    const handleSubmit = async (e) =&gt; {
      e.preventDefault();
  
      console.log('submitted!');
      signIn('credentials', {
        email: email,
        password: password,
        //   email: 'test@test.com',
        //   password: '1234',
        callbackUrl: 'http://localhost:3000/about',
        redirect: false,
      }).then(function (result) {
        console.log(result);
        if (result.error !== null) {
          if (result.status === 401) {
        setLoginError(
          'Your username/password combination was incorrect. Please try again'
        );
      } else {
        setLoginError(result.error);
      }
    } else {
      console.log(result);
      router.push(result.url);
    }
  });
    };
  
    return (
      &lt;form onSubmit={handleSubmit}&gt;
        &lt;label&gt;
          Email
          &lt;input
            name='email'
            type='text'
        value={email}
        onChange={(e) =&gt; setEmail(e.target.value)}
      /&gt;
    &lt;/label&gt;
    &lt;label&gt;
      Password
      &lt;input
        name='password'
        type='password'
        value={password}
        onChange={(e) =&gt; setPassword(e.target.value)}
      /&gt;
    &lt;/label&gt;
    &lt;button type='submit'&gt;Sign in&lt;/button&gt;
  &lt;/form&gt;
    );
  }
  </code></pre>
  <p>also here is my github repo for this whole code;
  <a href="https://github.com/sbayrak/nextauth-authentication" rel="nofollow noreferrer">GitHub Repo</a></p>
  <p>UPDATE: At first login, user info displays on the terminal but after I refresh the page, it says <code>undefined</code></p>