Im trying to create a temporary session in my API using nextJS version 14.2.3, this session needs to be created using a API-KEY and Bearer Token comming from the headers, but im getting this error, heres the code im trying to use:
`import { ApiError } from '@/lib/errors';import { throwIfNoAccessToApiKey } from '@/lib/guards/team-api-key'; // Adjust the import path based on your project structureimport { throwIfNoTeamAccess } from 'models/team';import { getOrders } from 'models/order';import type { NextApiRequest, NextApiResponse } from 'next';import { getServerSession } from 'next-auth';import NextAuth from 'next-auth';import { getAuthOptions } from '@/lib/nextAuth';export default async function handler(req: NextApiRequest, res: NextApiResponse) { try { const session = await getServerSession(getAuthOptions(req, res)); console.log("SESSION: ", session) const { teamId } = await throwIfNoTeamAccess(req, res); console.log("TEAM ID: ", teamId) switch (req.method) { case 'GET': await handleGET(req, res, teamId); break; default: res.setHeader('Allow', 'GET, POST, DELETE, PATCH'); res.status(405).end(`Method ${req.method} Not Allowed`); } } catch (error: any) { const message = error.message || 'Something went wrong'; const status = error.status || 500; res.status(status).json({ error: { message } }); }}`