Im currently trying to create a login as user route, wich works perfectly on production mode on localhost but not deployed on vercel.com
The route and session replacement works when i build it via npm run build and start it via npm run start on localhost:port but not via ip:port, but is completly unfunctional on my production deployment here on vercel.
import { NextResponse } from 'next/server';import { getServerSession } from 'next-auth';import { authOptions } from '@/lib/auth';import UserProfile from '@/models/UserProfile';import { encode } from 'next-auth/jwt';import { cookies } from 'next/headers';export async function POST(request: Request) { const session = await getServerSession(authOptions); if (!session || !session.user || !session.user.isAdmin) { return NextResponse.json({ error: 'Unauthorized' }, { status: 403 }); } const { userId } = await request.json(); const user = await UserProfile.findById(userId); if (!user) { return NextResponse.json({ error: 'User not found' }, { status: 404 }); } const token = await encode({ token: { id: user._id.toString(), username: user.username, isProUser: user.isProUser ?? false, isAdmin: user.isAdmin ?? false, role: user.role, sessionToken: user.sessionToken, },Deployment URL or Custom Domain: clipstocommunity.deEnvironment (production):productionProject Framework: nextjsNode/Runtime Version:20Package Manager: npmRelevant Packages: next-auth