NextJS getSession() is returning null

I’m using NextJS 12 with Auth0 but when I try to access the session from an api/route is always null.

import { getSession } from "@auth0/nextjs-auth0";
import { NextApiRequest, NextApiResponse } from "next";

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
) {
  const session = getSession(req, res);
  const user = session?.user;
  console.log("SESSION: ", { session }); // null
  
  res.json({ protected: "My Secret", id: user?.sub });
}

But when using getSession() from the page or getServerSideProps the session is returned corretly.

Is there something I’m missing?