Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

Add HOST environment

PlusaNf700f31904e2
diff --git a/server.js b/server.js
index b9b39988..5c83f81e 100644
--- a/server.js
+++ b/server.js
@@ -38,6 +38,9 @@ const isDocker = !!process.env.IS_DOCKER;
/* Checks env var for port. If undefined, will use Port 80 for Docker, or 4000 for metal */
const port = process.env.PORT || (isDocker ? 80 : 4000);
+/* Checks env var for host. If undefined, will use 0.0.0.0 */
+const host = process.env.HOST || '0.0.0.0';
+
/* Attempts to get the users local IP, used as part of welcome message */
const getLocalIp = () => {
const dnsLookup = util.promisify(dns.lookup);
@@ -48,7 +51,7 @@ const getLocalIp = () => {
const printWelcomeMessage = () => {
try {
getLocalIp().then(({ address }) => {
- const ip = address || 'localhost';
+ const ip = process.env.HOST || address || 'localhost';
console.log(printMessage(ip, port, isDocker)); // eslint-disable-line no-console
});
} catch (e) {
@@ -122,7 +125,7 @@ const app = express()
/* Create HTTP server from app on port, and print welcome message */
http.createServer(app)
- .listen(port, () => {
+ .listen(port, host, () => {
printWelcomeMessage();
})
.on('error', (err) => {