From df87c0168ecbbe612d6412d68d5d92636c3aa78b Mon Sep 17 00:00:00 2001 From: Paul Varache Date: Thu, 26 Sep 2019 17:47:30 +0100 Subject: [PATCH] fix: 404 is noice --- lib/spa-stream-protocol-handler.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/spa-stream-protocol-handler.js b/lib/spa-stream-protocol-handler.js index 1ef0efa..3813d3e 100644 --- a/lib/spa-stream-protocol-handler.js +++ b/lib/spa-stream-protocol-handler.js @@ -14,7 +14,12 @@ function getExtension(p) { } function getResponse(req, filePath) { - const fileStat = fs.statSync(filePath); + let fileStat; + try { + fileStat = fs.statSync(filePath); + } catch (e) { + return { status: 404, headers: {}, stream: fs.createReadStream(filePath) }; + } const headers = {}; // Handle video/audio streaming (or seeking) if (req.headers.Range) {