Mark /api/events endpoint as uncachable
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:
parent
a32a49b281
commit
1826529bc8
1 changed files with 1 additions and 0 deletions
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue