MotorSignal-App/website/app/api/account/sessions/[sessionId]/route.ts

12 lines
848 B
TypeScript

import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
export async function DELETE(request: NextRequest, context: { params: Promise<{ sessionId: string }> }) {
const token = (await cookies()).get('motorsignal_access_token')?.value;
if (!token) return NextResponse.json({ detail: 'Authentication required.' }, { status: 401 });
const { sessionId } = await context.params;
const baseUrl = process.env.MOTORSIGNAL_API_BASE_URL ?? 'https://api.motorsignal.app';
const response = await fetch(`${baseUrl}/api/v1/auth/sessions/${sessionId}`, { method: 'DELETE', headers: { authorization: `Bearer ${token}` }, cache: 'no-store' });
return new NextResponse(await response.text(), { status: response.status, headers: { 'content-type': response.headers.get('content-type') ?? 'application/json' } });
}