0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

Merge pull request #1299 from verdaccio/fix-1297

fix: routing is aware of reverse proxy directory #1297
This commit is contained in:
Juan Picado @jotadeveloper 2019-05-07 07:07:35 +02:00 committed by GitHub
commit 1bdb338092
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View file

@ -17,7 +17,7 @@
"dependencies": {
"@verdaccio/local-storage": "2.1.0",
"@verdaccio/streams": "2.0.0",
"@verdaccio/ui-theme": "0.1.2",
"@verdaccio/ui-theme": "0.1.5",
"JSONStream": "1.3.5",
"async": "3.0.1-0",
"body-parser": "1.19.0",

View file

@ -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);

BIN
yarn.lock

Binary file not shown.