Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server.js replace node-static with serve-static #889

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down