Skip to content

Commit

Permalink
fix: 🐛 incorrect resource and registry url while install on sub direc…
Browse files Browse the repository at this point in the history
…tory
  • Loading branch information
64b2b6d12bfe4baae7dad3d01 committed Oct 31, 2017
1 parent aa7fb65 commit 67e97a1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/api/web/index.js
Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions src/webui/src/components/Header/index.js
Expand Up @@ -138,16 +138,19 @@ 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 }>
<Link to="/">
<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>
Expand Down
7 changes: 5 additions & 2 deletions src/webui/src/components/Help/index.js
Expand Up @@ -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}>
Expand All @@ -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>
Expand Down

0 comments on commit 67e97a1

Please sign in to comment.