diff --git a/pages/api/token/index.ts b/pages/api/token/index.ts new file mode 100644 index 000000000..f68ad2e27 --- /dev/null +++ b/pages/api/token/index.ts @@ -0,0 +1,15 @@ +import { NextApiRequest, NextApiResponse } from "next"; +import { getToken } from "next-auth/jwt"; + +export default async function handler(req: NextApiRequest, res: NextApiResponse) { + const { method } = req; + + const secret = process.env.NEXTAUTH_SECRET; + + switch (method) { + case "GET": + const jwt = await getToken({ req, secret, raw: true }); + res.status(200).json(jwt); + break; + } +}