Add support for running under a context path, ie. /bonob, replace BONOB_WEB_ADDRESS with BONOB_URL

This commit is contained in:
simojenki
2021-07-23 18:11:32 +10:00
parent 8ed9bef7d8
commit 1153f8e318
16 changed files with 3700 additions and 3053 deletions

View File

@@ -1,28 +1,32 @@
import { hostname } from "os";
import logger from "./logger";
import url from "./url_builder";
export default function () {
const port = +(process.env["BONOB_PORT"] || 4534);
const webAddress =
process.env["BONOB_WEB_ADDRESS"] || `http://${hostname()}:${port}`;
const bonobUrl =
process.env["BONOB_URL"] ||
process.env["BONOB_WEB_ADDRESS"] ||
`http://${hostname()}:${port}`;
if (webAddress.match("localhost")) {
if (bonobUrl.match("localhost")) {
logger.error(
"BONOB_WEB_ADDRESS containing localhost is almost certainly incorrect, sonos devices will not be able to communicate with bonob using localhost, please specify either public IP or DNS entry"
"BONOB_URL containing localhost is almost certainly incorrect, sonos devices will not be able to communicate with bonob using localhost, please specify either public IP or DNS entry"
);
process.exit(1);
}
return {
port,
webAddress,
bonobUrl: url(bonobUrl),
secret: process.env["BONOB_SECRET"] || "bonob",
sonos: {
serviceName: process.env["BONOB_SONOS_SERVICE_NAME"] || "bonob",
deviceDiscovery:
(process.env["BONOB_SONOS_DEVICE_DISCOVERY"] || "true") == "true",
seedHost: process.env["BONOB_SONOS_SEED_HOST"],
autoRegister: (process.env["BONOB_SONOS_AUTO_REGISTER"] || "false") == "true",
autoRegister:
(process.env["BONOB_SONOS_AUTO_REGISTER"] || "false") == "true",
sid: Number(process.env["BONOB_SONOS_SERVICE_ID"] || "246"),
},
navidrome: {
@@ -31,6 +35,7 @@ export default function () {
process.env["BONOB_NAVIDROME_CUSTOM_CLIENTS"] || undefined,
},
scrobbleTracks: (process.env["BONOB_SCROBBLE_TRACKS"] || "true") == "true",
reportNowPlaying: (process.env["BONOB_REPORT_NOW_PLAYING"] || "true") == "true",
reportNowPlaying:
(process.env["BONOB_REPORT_NOW_PLAYING"] || "true") == "true",
};
}