mirror of https://github.com/Lissy93/dashy.git
🔀 Merge pull request #671 from PlusaN/patch-1
Add HOST environment Fixes #667
This commit is contained in:
commit
ec39a8bce5
|
@ -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) => {
|
||||
|
|
Loading…
Reference in New Issue