Files
Noel Sabia 66b80a62fb
ci / check (push) Successful in 1m20s
ci / check (pull_request) Successful in 51s
docs: tighten README quick start and stale comments
- Lead with purpose and exact local/CI commands.
- Remove local absolute paths, stale auth notes and unverified claims.
- Keep comments to the reason or invariant they protect.
2026-11-14 09:16:19 +01:00

21 lines
757 B
TypeScript

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' },
})
})