1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00

fix: routing is aware of reverse proxy directory #1297

This commit is contained in:
Juan Picado @jotadeveloper 2019-05-02 21:29:47 +02:00
parent 9589d47ff7
commit 01f8da6366
No known key found for this signature in database
GPG Key ID: 18AC54485952D158

@ -75,14 +75,25 @@ module.exports = function(config, auth, storage) {
});
function renderHTML(req, res) {
const base = combineBaseUrl(getWebProtocol(req.get(HEADERS.FORWARDED_PROTO), req.protocol), req.get('host'), config.url_prefix);
const protocol = getWebProtocol(req.get(HEADERS.FORWARDED_PROTO), req.protocol);
const host = req.get('host');
const { url_prefix } = config;
const uri = `${protocol}://${host}`;
const base = combineBaseUrl(protocol, host, url_prefix);
const primaryColor = _.get(config, 'web.primary_color') ? config.web.primary_color : '';
const title = _.get(config, 'web.title') ? config.web.title : WEB_TITLE;
const scope = _.get(config, 'web.scope') ? config.web.scope : '';
const options = { uri, protocol, host, url_prefix, base, primaryColor, title, scope };
const webPage = template
.replace(/ToReplaceByVerdaccioUI/g, JSON.stringify(options))
.replace(/ToReplaceByVerdaccio/g, base)
.replace(/ToReplaceByPrefix/g, url_prefix)
.replace(/ToReplaceByVersion/g, pkgJSON.version)
.replace(/ToReplaceByTitle/g, _.get(config, 'web.title') ? config.web.title : WEB_TITLE)
.replace(/ToReplaceByTitle/g, title)
.replace(/ToReplaceByLogo/g, logoURI)
.replace(/ToReplaceByPrimaryColor/g, _.get(config, 'web.primary_color') ? config.web.primary_color : '')
.replace(/ToReplaceByScope/g, _.get(config, 'web.scope') ? config.web.scope : '');
.replace(/ToReplaceByPrimaryColor/g, primaryColor)
.replace(/ToReplaceByScope/g, scope);
res.setHeader('Content-Type', HEADERS.TEXT_HTML);