import { existsSync, readFileSync } from 'node:fs' export default defineEventHandler((event) => { assertLibraryAccess(event) const id = String(getRouterParam(event, 'id') || '') const clip = getClip(id) const path = clipVideoPath(clip.id) if (!existsSync(path)) { throw createError({ statusCode: 404, statusMessage: 'Video file is missing' }) } setHeader(event, 'Content-Type', 'video/mp4') setHeader(event, 'Content-Disposition', `inline; filename="${clip.id}.mp4"`) setHeader(event, 'Cache-Control', 'private, max-age=3600') return readFileSync(path) })