Files
sim/apps/sim/app/api/copilot/chat/abort/route.ts
Siddharth Ganesan b5c2070baf Fix signaling
2026-03-10 16:47:57 -07:00

23 lines
802 B
TypeScript

import { NextResponse } from 'next/server'
import { abortActiveStream } from '@/lib/copilot/chat-streaming'
import { authenticateCopilotRequestSessionOnly } from '@/lib/copilot/request-helpers'
export async function POST(request: Request) {
const { userId: authenticatedUserId, isAuthenticated } =
await authenticateCopilotRequestSessionOnly()
if (!isAuthenticated || !authenticatedUserId) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const body = await request.json().catch(() => ({}))
const streamId = typeof body.streamId === 'string' ? body.streamId : ''
if (!streamId) {
return NextResponse.json({ error: 'streamId is required' }, { status: 400 })
}
const aborted = abortActiveStream(streamId)
return NextResponse.json({ aborted })
}