From 2a5326f993989a1caffcc08a3705e3a837c18785 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Thu, 25 Jul 2024 17:34:38 -0500 Subject: [PATCH] Fixed the header handling --- server.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/server.js b/server.js index d5814ab..fc8697a 100644 --- a/server.js +++ b/server.js @@ -31,7 +31,7 @@ http.createServer(function(req, res) { } } else { console.log("RCV-HTML"); - res.writeHead(200, { 'Content-Type': 'text/html', 'Cache-Control': 'no-cache' ,'Access-Control-Allow-Origin': '*' }); + //res.writeHead(200, { 'Content-Type': 'text/html', 'Cache-Control': 'no-cache' ,'Access-Control-Allow-Origin': '*' }); arrMatches = req.url.match(new RegExp(/\/(save|raw)\/(.*)$/)); console.log("Matches", arrMatches); if ((arrMatches) && (arrMatches.length === 3)) { @@ -100,18 +100,10 @@ http.createServer(function(req, res) { console.log("Full path " + filePath + " [" + contentType + "]" ); try { - console.log("A"); var stat = fs.statSync(filePath); - - console.log("B"); var readStream = fs.createReadStream(filePath); - console.log("C"); - res.writeHead(200, {"Content-Type":contentType}); - - console.log("D"); + res.writeHead(200, { 'Content-Type': contentType, 'Cache-Control': 'no-cache' ,'Access-Control-Allow-Origin': '*' }); readStream.pipe(res); // this will do a res.end() by its own. - console.log("E"); - } catch (ex) { res.writeHead(404,{"Content-Type":"text/html"}); res.write("Not found: " + reqFile ); @@ -130,7 +122,8 @@ function sendSSE(req, res) { res.writeHead(200, { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', - 'Connection': 'keep-alive' + 'Connection': 'keep-alive', + 'Access-Control-Allow-Origin': '*' }); var id = (new Date()).toLocaleTimeString();