Mark /api/events endpoint as uncachable
All checks were successful
/ build (push) Successful in 1m27s
/ deploy (push) Has been skipped

The content of the events stream is generated live in response to
changes done in the system as they occur.  It therefore can't be
meaningfully cached or stored in any way.  Mark the response as
uncacheable to prevent potential problems with caches.
This commit is contained in:
Hornwitser 2025-09-21 23:20:48 +02:00
parent a32a49b281
commit 1826529bc8

View file

@ -43,6 +43,7 @@ export default defineEventHandler(async (event) => {
// Workaround to properly handle stream errors. See https://github.com/unjs/h3/issues/986
setHeader(event, "Access-Control-Allow-Origin", "*");
setHeader(event, "Content-Type", "text/event-stream");
setHeader(event, "Cache-Control", "no-store");
pipeline(stream as unknown as NodeJS.ReadableStream, event.node.res, (err) => { /* ignore */ });
event._handled = true;
});