Merge pull request #1284 from akihikodaki/master

Pass hostname instead of host to vhost module
This commit is contained in:
syuilo 2018-03-25 22:51:45 +09:00 committed by GitHub
commit 687cd56cc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,11 @@ import vhost = require('vhost');
import log from './log-request';
import config from './conf';
function extractHostname(host) {
const index = host.indexOf(':');
return index < 0 ? host : host.substr(0, index);
}
/**
* Init app
*/
@ -53,9 +58,11 @@ app.use((req, res, next) => {
/**
* Register modules
*/
app.use(vhost(`api.${config.host}`, require('./api/server')));
app.use(vhost(config.secondary_host, require('./himasaku/server')));
app.use(vhost(`file.${config.secondary_host}`, require('./file/server')));
const hostname = extractHostname(config.host);
const secondaryHostname = extractHostname(config.secondary_host);
app.use(vhost(`api.${hostname}`, require('./api/server')));
app.use(vhost(secondaryHostname, require('./himasaku/server')));
app.use(vhost(`file.${secondaryHostname}`, require('./file/server')));
app.use(require('./web/server'));
/**