Add SSE headers
continuous-integration/drone/push Build is passing Details

pull/1/head
Clément FRÉVILLE 1 year ago
parent 5fb98c0395
commit bfbc86cde3

@ -31,6 +31,15 @@ fastify.post('/run', {
const { code, language } = req.body;
const jobId = generateId();
const buffer = allocateBuffer(jobId, code, IMAGES.moshell);
reply.raw.writeHead(200, {
'Content-Type': 'text/event-stream',
Connection: 'keep-alive',
'Cache-Control': 'no-cache',
'Access-Control-Allow-Origin': process.env.ALLOW_ORIGIN || '*',
});
reply.raw.on('close', () => {
delete clients[jobId];
});
sender.send(buffer).then(() => {
reply.raw.write('event: connected\n');
reply.raw.write(`data: ${jobId}\n`);

Loading…
Cancel
Save