From 6a30ab066a964b111283db4d44819bb59089102d Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Thu, 19 Oct 2023 11:49:45 +0200 Subject: [PATCH] fix: set default host to undefined (#3362) --- .env.app.example | 2 +- app.ts | 4 ++-- bin/www.ts | 2 +- config/app.ts | 2 +- docs/guide/env-vars.md | 2 +- src/views/Settings.vue | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.env.app.example b/.env.app.example index 1db0797a967..729dbd42c03 100644 --- a/.env.app.example +++ b/.env.app.example @@ -1,4 +1,4 @@ -# The host address to bind to. Default is `::` +# The host address to bind to # HOST="::" # The port to listen to for incoming requests. Default is `8091` # PORT=8091 diff --git a/app.ts b/app.ts index da8ccf21aeb..368c3435b4b 100644 --- a/app.ts +++ b/app.ts @@ -170,7 +170,7 @@ let restarting = false /** * Start http/https server and all the manager */ -export async function startServer(host: string, port: number | string) { +export async function startServer(port: number | string, host?: string) { let server: HttpServer const settings = jsonStore.get(store.settings) @@ -215,7 +215,7 @@ export async function startServer(host: string, port: number | string) { const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr?.port logger.info( - `Listening on ${bind} host ${host} protocol ${ + `Listening on ${bind}${host ? 'host ' + host : ''} protocol ${ httpsEnabled ? 'HTTPS' : 'HTTP' }`, ) diff --git a/bin/www.ts b/bin/www.ts index 2e5e62f4684..d6dc20f34a9 100644 --- a/bin/www.ts +++ b/bin/www.ts @@ -46,7 +46,7 @@ jsonStore const port = normalizePort(conf.port) app.set('port', port) - return startServer(conf.host, port) + return startServer(port, conf.host) }) .catch((err: unknown) => { console.error(err) diff --git a/config/app.ts b/config/app.ts index f609cf74a46..10a0adecd82 100644 --- a/config/app.ts +++ b/config/app.ts @@ -21,4 +21,4 @@ export const defaultPsw: string = 'zwave' export const sessionSecret: string = process.env.SESSION_SECRET || 'DEFAULT_SESSION_SECRET_CHANGE_ME' export const base: string = process.env.BASE_PATH || '/' export const port: string | number = process.env.PORT || 8091 -export const host: string = process.env.HOST || '::' \ No newline at end of file +export const host: string = process.env.HOST // by default undefined, so it will listen on all interfaces both ipv4 and ipv6 \ No newline at end of file diff --git a/docs/guide/env-vars.md b/docs/guide/env-vars.md index 25776b91f04..ef06a9d4ee5 100644 --- a/docs/guide/env-vars.md +++ b/docs/guide/env-vars.md @@ -15,7 +15,7 @@ This is the list of the supported environment variables: - `SESSION_SECRET`: Used as secret for session. If not provided the default one is used - `USE_SECURE_COOKIE`: Set the cookie [secure](https://github.com/expressjs/session#cookiesecure) option. - `PORT`: The port to listen to for incoming requests. Default is `8091` -- `HOST`: The host address to bind to. Default is `::` +- `HOST`: The host address to bind to. Keep it empty to bind to all interfaces both IPv4 and IPv6 - `STORE_DIR`: The absolute path to the directory where all files will be stored. Default is `/store` - `BACKUPS_DIR`: The absolute path to the directory where all backups files will be stored. Default is `/store/backups` - `ZWAVEJS_EXTERNAL_CONFIG`: Mostly needed for docker users, it's the path to the folder used by Z-Wave JS to [store config database](https://zwave-js.github.io/node-zwave-js/#/usage/external-config?id=specifying-an-external-config-db-location), by default on docker it is `/usr/src/app/store/.config-db`. For users that are using a custom `STORE_DIR` this must be changed too. diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 6554fcad33e..a49d28f12a9 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -1233,7 +1233,7 @@