import { apiBaseUrl, isMockMode } from '../utils/api' /** * Same-origin SSE proxy: the browser talks only to Nitro, so CORS stays closed. * proxyRequest forwards chunks as they arrive, preserving heartbeats and retry hints. */ export default defineEventHandler(async (event) => { if (isMockMode() || process.env.NUXT_DISABLE_SSE === '1') { // Failure drill: make the client prove the 5 s polling fallback. Mock mode // has no upstream stream either, so both paths fail fast and visibly. throw createError({ statusCode: 503, statusMessage: 'SSE is disabled; the scenario polling fallback is active.', }) } return proxyRequest(event, `${apiBaseUrl()}/api/stream`, { headers: { accept: 'text/event-stream' }, }) })