From b5e1c8e1656b65b46cdb3abe862fc99290353403 Mon Sep 17 00:00:00 2001 From: Mathew Henson Date: Thu, 23 Jun 2016 13:29:58 +0100 Subject: [PATCH] Split the host property of the config into host and hostName. Host is used for connecting to the node server and hostName is an external URL of the host name. --- src/definitions/custom/definitions.d.ts | 10 ++++++++-- src/dist-files/example-config.json | 3 ++- src/startup.ts | 8 ++++---- src/users.ts | 4 ++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/definitions/custom/definitions.d.ts b/src/definitions/custom/definitions.d.ts index 37509c9..9d42f47 100644 --- a/src/definitions/custom/definitions.d.ts +++ b/src/definitions/custom/definitions.d.ts @@ -381,11 +381,17 @@ debugMode: boolean; /** - * The domain or host of the site. - * eg: "127.0.0.1" or "webinate.net" + * The host to use when listening + * eg: "localhost" or "192.168.0.1" or "0.0.0.0" */ host: string; + /** + * The domain or host name of the site. This is the external URL to use for connecting to users. + * eg: "webinate.net" + */ + hostName: string; + /** * The RESTful path of this service. * eg: If "/api", then the API url would be 127.0.0.1:80/api (or rather host:port/api) diff --git a/src/dist-files/example-config.json b/src/dist-files/example-config.json index e6ab084..4211169 100644 --- a/src/dist-files/example-config.json +++ b/src/dist-files/example-config.json @@ -1,5 +1,6 @@ { - "host": "127.0.0.1", + "host": "localhost", + "hostName" : "webinate.net", "apiPrefix": "/", "accountRedirectURL": "http://host.com/admin/message", "passwordResetURL": "http://host.com/admin/password-reset-form", diff --git a/src/startup.ts b/src/startup.ts index bd1a95b..b8d2191 100644 --- a/src/startup.ts +++ b/src/startup.ts @@ -95,8 +95,8 @@ openDB(config).then(function (db) // Start node server.js var httpServer = http.createServer(app); - httpServer.listen( {port: config.portHTTP, host: "localhost"} ); - winston.info(`Listening on HTTP port ${config.portHTTP}`, { process: process.pid }); + httpServer.listen( {port: config.portHTTP, host: config.host } ); + winston.info(`Listening on ${config.host}:${config.portHTTP}`, { process: process.pid }); // If we use SSL then start listening for that as well if (config.ssl) @@ -133,9 +133,9 @@ openDB(config).then(function (db) winston.info(`Attempting to start SSL server...`, { process: process.pid }); var httpsServer = https.createServer({ key: privkey, cert: theCert, passphrase: config.sslPassPhrase, ca: caChain }, app); - httpsServer.listen( {port: port, host: "localhost"} ); + httpsServer.listen( {port: port, host: config.host} ); - winston.info(`Listening on HTTPS port ${port}`, { process: process.pid }); + winston.info(`Listening on HTTPS ${config.host}:${port}`, { process: process.pid }); } // Done! diff --git a/src/users.ts b/src/users.ts index ec7f1f0..d7c8717 100644 --- a/src/users.ts +++ b/src/users.ts @@ -200,7 +200,7 @@ export class UserManager // If no admin user exists, so lets try to create one if (!user) - user = await this.createUser(config.adminUser.username, config.adminUser.email, config.adminUser.password, (config.ssl ? "https://" : "http://") + config.host, UserPrivileges.SuperAdmin, {}, true); + user = await this.createUser(config.adminUser.username, config.adminUser.email, config.adminUser.password, (config.ssl ? "https://" : "http://") + config.hostName, UserPrivileges.SuperAdmin, {}, true); return; } @@ -280,7 +280,7 @@ export class UserManager */ private createActivationLink( user : User, origin : string ): string { - return `${(this._config.ssl ? "https://" : "http://") }${this._config.host }:${(this._config.ssl ? this._config.portHTTPS : this._config.portHTTP) }${this._config.apiPrefix}activate-account?key=${user.dbEntry.registerKey}&user=${user.dbEntry.username}&origin=${origin}`; + return `${(this._config.ssl ? "https://" : "http://") }${this._config.hostName }:${(this._config.ssl ? this._config.portHTTPS : this._config.portHTTP) }${this._config.apiPrefix}activate-account?key=${user.dbEntry.registerKey}&user=${user.dbEntry.username}&origin=${origin}`; } /**