title: Deploying next-auth app to Vercel creates error in credentials provider
body: <p>I am trying to deploy my next app to vercel. I am using next-auth for authentication with credentials and an api that returns a JWT. On localhost it works ok, but when I put it on vercel, and try to login, nothing happens. However when I view the logs in the project's dashboard functions, there's an error:</p>
  <pre><code>[POST] /api/auth/callback/credentials
  03:32:18:58
  2021-12-21T00:32:19.071Z    410db3c3-d841-45d1-8df2-0cdbb4aa8793    ERROR   TypeError: &quot;ikm&quot;&quot; must be an instance of Uint8Array or a string
      at normalizeUint8Array (/var/task/node_modules/@panva/hkdf/dist/node/cjs/index.js:20:15)
      at normalizeIkm (/var/task/node_modules/@panva/hkdf/dist/node/cjs/index.js:24:17)
      at hkdf (/var/task/node_modules/@panva/hkdf/dist/node/cjs/index.js:47:60)
      at getDerivedEncryptionKey (/var/task/node_modules/next-auth/jwt/index.js:99:34)
      at Object.encode (/var/task/node_modules/next-auth/jwt/index.js:45:34)
      at Object.callback (/var/task/node_modules/next-auth/core/routes/callback.js:457:37)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async NextAuthHandler (/var/task/node_modules/next-auth/core/index.js:197:28)
      at async NextAuthNextHandler (/var/task/node_modules/next-auth/next/index.js:40:7)
      at async Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils.js:101:9)
  2021-12-21T00:32:19.071Z    410db3c3-d841-45d1-8df2-0cdbb4aa8793    ERROR   TypeError: &quot;ikm&quot;&quot; must be an instance of Uint8Array or a string
      at normalizeUint8Array (/var/task/node_modules/@panva/hkdf/dist/node/cjs/index.js:20:15)
      at normalizeIkm (/var/task/node_modules/@panva/hkdf/dist/node/cjs/index.js:24:17)
      at hkdf (/var/task/node_modules/@panva/hkdf/dist/node/cjs/index.js:47:60)
      at getDerivedEncryptionKey (/var/task/node_modules/next-auth/jwt/index.js:99:34)
      at Object.encode (/var/task/node_modules/next-auth/jwt/index.js:45:34)
      at Object.callback (/var/task/node_modules/next-auth/core/routes/callback.js:457:37)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async NextAuthHandler (/var/task/node_modules/next-auth/core/index.js:197:28)
      at async NextAuthNextHandler (/var/task/node_modules/next-auth/next/index.js:40:7)
      at async Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils.js:101:9)
  RequestId: 410db3c3-d841-45d1-8df2-0cdbb4aa8793 Error: Runtime exited with error: exit status 1
  Runtime.ExitError
  </code></pre>
  <p>Additional info:
  The <code>SignIn()</code> function looks like this:</p>
  <pre><code>signIn(&quot;credentials&quot;, {
          email: values.name,
          password: values.password,
          redirect: false,
          callbackUrl: `/app`
        })
          .then((data) =&gt; console.log(&quot;loginpagethen&quot;, data))
          .catch((error) =&gt; console.log(&quot;loginpagecatch&quot;, error));
  </code></pre>
  <p>I think the problem occurs somewhere in the <code>jwt callback</code> function because <code>authorize</code> returns a user(with all the data, including jwt from server). Also if I console.log the user in the <code>jwt callback</code> function,I can actually see the user object. However the session isn't present.</p>
  <pre><code> async jwt({ token, user, account, profile, isNewUser }) {
      if (user) {
        console.log(&quot;user&quot;, user); //user is there
        token.accessToken = user.token;
      }
      return token;
    },
  
    async session(session, token) {
      console.log(&quot;session&quot;, session); //session is not there
      return session;
    },
  };
  </code></pre>
  <p>P.S. I have added environment variables.</p>
  <p>Any idea on how I can get my app to behave on vercel?</p>