title: NextAuth with custom Credential Provider Not creating session
body: <p>I am attempting to implement NextAuth in my NextJs app. I am following the official documentation. But for one reason or the other, it seems like the user session object is not generated on login.</p>
  <p>Here is my code from my pages/api/auth/[...nextauth].js file</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import NextAuth from "next-auth";
  import Providers from "next-auth/providers";
  import axios from "axios";
  
  
  export default (req, res) =&gt;
      NextAuth(req, res, {
          providers: [
              Providers.Credentials({
                  id: 'app-login',
                  name: APP
                  authorize: async (credentials) =&gt; {
                      console.log("credentials_:", credentials);
                      try {
                          const data = {
                              username: credentials.username,
                              password: credentials.password
  
                          }
                          // API call associated with authentification
                           // look up the user from the credentials supplied
                          const user = await login(data);
                          if (user) {
                              // Any object returned will be saved in `user` property of the JWT
                              return Promise.resolve(user);
                            }
                       
                      } catch (error) {
                          if (error.response) {
  
                              console.log(error.response);
                              Promise.reject(new Error('Invalid Username  and Password combination'));
                          }
                      }
  
                      
  
                  },
                 
              }),
          ],
          site: process.env.NEXTAUTH_URL || "http://localhost:3000",
          session: {
              // Use JSON Web Tokens for session instead of database sessions.
              // This option can be used with or without a database for users/accounts.
              // Note: `jwt` is automatically set to `true` if no database is specified.
              jwt: true, 
              
              // Seconds - How long until an idle session expires and is no longer valid.
              maxAge: 1 * 3 * 60 * 60, // 3 hrs
              
              // Seconds - Throttle how frequently to write to database to extend a session.
              // Use it to limit write operations. Set to 0 to always update the database.
              // Note: This option is ignored if using JSON Web Tokens 
              updateAge: 24 * 60 * 60, // 24 hours
            },
            callbacks: { 
              // signIn: async (user, account, profile) =&gt; { return Promise.resolve(true) },
              // redirect: async (url, baseUrl) =&gt; { return Promise.resolve(baseUrl) },
              // session: async (session, user) =&gt; { return Promise.resolve(session) },
              // jwt: async (token, user, account, profile, isNewUser) =&gt; { return Promise.resolve(token) }
            },
          pages: {
              signIn: '/auth/credentials-signin',
              signOut: '/auth/credentials-signin?logout=true',
              error: '/auth/credentials-signin', // Error code passed in query string as ?error=
              newUser:'/'
            },
  
          debug: process.env.NODE_ENV === "development",
          secret: process.env.NEXT_PUBLIC_AUTH_SECRET,
          jwt: {
              secret: process.env.NEXT_PUBLIC_JWT_SECRET,
          }
      });
  
  
  
  
  
  
  const login = async data =&gt; {
      var config = {
          headers: {
              'Content-Type': "application/json; charset=utf-8",
              'corsOrigin': '*',
              "Access-Control-Allow-Origin": "*"
          }
      };
      const url = remote_user_url;
      const result = await axios.post(url, data, config);
      console.log('result', result);
      return result;
  };</code></pre>
  </div>
  </div>
  </p>
  <p>What am I not getting it right here? Thanks for the help.</p>