feat: live SSE stage, phone view and presenter control
- proxy Go /api/stream through Nitro; drive /stage, /live, /plan and /forecast from scenario events - fall back to 5 s polling after SSE failures or heartbeat silence; show Live/Polling/Offline - authenticate /control and POST /api/scenario in Nitro with server-side control credentials - add big-screen stage with local QR and a no-login phone recommendation view - add SSE unit tests and a live smoke test; refresh README/Makefile
This commit is contained in:
1 parent
7181562e0f
commit
233fdbf66c
24 files changed
+2757
-49
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { apiBaseUrl, isMockMode } from '../utils/api'
|
||||
|
||||
/**
|
||||
* Same-origin SSE proxy. The browser never talks to Go directly, so the
|
||||
* Cloudflare/K8s CORS surface stays closed and the stream can be cached or
|
||||
* authenticated at one edge only.
|
||||
*
|
||||
* h3's proxyRequest pipes response chunks as they arrive (it does not await
|
||||
* the full body), which preserves the 15 s heartbeat and `retry: 3000`.
|
||||
*/
|
||||
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' },
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user