0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-17 23:45:29 -05:00

Merge pull request #393 from Meeeeow/fix_sub_directory_resource_url

fix: 🐛 incorrect resource and registry url while install on sub directory
This commit is contained in:
Juan Picado @jotadeveloper 2017-10-31 18:38:09 +01:00 committed by GitHub
commit bcf79c476d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View file

@ -33,7 +33,9 @@ module.exports = function(config, auth, storage) {
});
router.get('/-/verdaccio/logo', function(req, res) {
res.send(_.get(config, 'web.logo') || '/-/static/logo.png');
const installPath = _.get(config, 'url_prefix', '');
res.send(_.get(config, 'web.logo') || `${installPath}/-/static/logo.png`);
});
router.get('/', function(req, res) {

View file

@ -138,6 +138,9 @@ export default class Header extends React.Component {
}
render() {
// Don't add slash if it's not a sub directory
const registryURL = `${location.origin}${location.pathname === '/' ? '' : location.pathname}`;
return (
<header className={ classes.header }>
<div className={ classes.headerWrap }>
@ -145,9 +148,9 @@ export default class Header extends React.Component {
<img src={ this.state.logo } className={ classes.logo } />
</Link>
<figure>
npm set registry { location.origin }
npm set registry { registryURL }
<br/>
npm adduser --registry { location.origin }
npm adduser --registry { registryURL }
</figure>
{this.renderUserActionButton()}
</div>

View file

@ -9,6 +9,9 @@ import classes from './help.scss';
registerLanguage('javascript', js);
const Help = () => {
// Don't add slash if it's not a sub directory
const registryURL = `${location.origin}${location.pathname === '/' ? '' : location.pathname}`;
return (
<div className={classes.help}>
<li className={classes.noPkg}>
@ -24,11 +27,11 @@ const Help = () => {
1. Login
</strong>
<SyntaxHighlighter language='javascript' style={sunburst}>
{`npm adduser --registry ${location.origin}`}
{`npm adduser --registry ${registryURL}`}
</SyntaxHighlighter>
<strong>2. Publish</strong>
<SyntaxHighlighter language='javascript' style={sunburst}>
{`npm publish --registry ${location.origin}`}
{`npm publish --registry ${registryURL}`}
</SyntaxHighlighter>
<strong>3. Refresh this page!</strong>
</p>