Skip to content

Commit

Permalink
Split the host property of the config into host and hostName. Host is…
Browse files Browse the repository at this point in the history
… used for connecting to the node server and hostName is an external URL of the host name.
  • Loading branch information
MKHenson committed Jun 23, 2016
1 parent 42224fa commit b5e1c8e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/definitions/custom/definitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/dist-files/example-config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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!
Expand Down
4 changes: 2 additions & 2 deletions src/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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}`;
}

/**
Expand Down

0 comments on commit b5e1c8e

Please sign in to comment.