From 1357ec2d5524e6a26fb16fdda9ddae58558fd95d Mon Sep 17 00:00:00 2001 From: crissmil Date: Tue, 7 May 2024 00:42:07 +0300 Subject: [PATCH 1/2] server.js replace node-static with serve-static --- server.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index b795e13c..f59d6abd 100644 --- a/server.js +++ b/server.js @@ -6,22 +6,22 @@ const auth = require('basic-auth'); const SonosSystem = require('sonos-discovery'); const logger = require('sonos-discovery/lib/helpers/logger'); const SonosHttpAPI = require('./lib/sonos-http-api.js'); -const nodeStatic = require('node-static'); +const serveStatic = require('serve-static'); const settings = require('./settings'); -const fileServer = new nodeStatic.Server(settings.webroot); +const serve = new serveStatic(settings.webroot); const discovery = new SonosSystem(settings); const api = new SonosHttpAPI(discovery, settings); var requestHandler = function (req, res) { req.addListener('end', function () { - fileServer.serve(req, res, function (err) { + serve(req, res, function (err) { // If error, route it. // This bypasses authentication on static files! - if (!err) { - return; - } + //if (!err) { + // return; + //} if (settings.auth) { var credentials = auth(req); From c7f60e43038a603606d0e9c5a845a09f0ebb660f Mon Sep 17 00:00:00 2001 From: crissmil Date: Tue, 7 May 2024 00:48:23 +0300 Subject: [PATCH 2/2] Update package.json with serve-static --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f930b987..5730bd53 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "json5": "^0.5.1", "mime": "^1.4.1", "music-metadata": "^1.1.0", - "node-static": "^0.7.9", + "serve-static": "^1.15.0", "request-promise": "~1.0.2", "sonos-discovery": "https://github.com/jishi/node-sonos-discovery/archive/v1.7.3.tar.gz", "wav-file-info": "0.0.8",