title: NextJS next-auth get session always null
body: <p>Can't get the session data using getSession({req}) on a api call?
  useSession() on a component is working fine.</p>
  <p>package versions: nextjs@12.01, next-auth@4.3.1</p>
  <p>issue: api/lists.ts:</p>
  <pre><code>import prisma from &quot;../../../lib/prisma&quot;;
  import { getSession } from &quot;next-auth/react&quot;
      
  export default async (req: NextApiRequest, res: NextApiResponse) =&gt; {
    
       const session = await getSession({ req });
       console.log('session data is always null', session);
  </code></pre>
  <p>nexuauth.js config file:</p>
  <pre><code>callbacks: {
          session: async ({ session, user, token }) =&gt; {
              if (session?.user) {
                  session.user.id = user.id;
              }
              // console.log('session callback', session);
              return session;
          },
      },
      session: { strategy: &quot;database&quot; },
  </code></pre>
  <p>_app.js file:</p>
  <pre><code>function MyApp({ Component, ...pageProps }) {
    return (
      &lt;SessionProvider session={pageProps.session} refetchInterval={5 * 60}&gt;
        &lt;Main&gt;
          &lt;Component {...pageProps} /&gt;
        &lt;/Main&gt;
      &lt;/SessionProvider&gt;
    )
  }
  
  export default MyApp
  </code></pre>
  <p>on a login.js file (working fine):</p>
  <pre><code>export default function Login() {
  
      const { data: session } = useSession()
  </code></pre>