Skip to content
This repository has been archived by the owner on Apr 1, 2021. It is now read-only.

nginx relative path example depends on assets served from root #29

Open
bsh-ableton opened this issue Nov 4, 2019 · 1 comment
Open

Comments

@bsh-ableton
Copy link

bsh-ableton commented Nov 4, 2019

Hello,

I just bumped into a little snag trying to use Verdaccio in an environment where it is reverse-proxied with a url_prefix. I thought I'd document what I found; hopefully this is helpful!

summary

In the nginx reverse proxy example with a relative path, the Verdaccio instance at /verdaccio/ points to the static assets served by the instance at /.

Because both of these instances are the same version, it conceals an underlying issue: that setting a url_prefix in Verdaccio v4's config.yaml doesn't lead to the url_prefix being used for the accompanying static assets.

reproduction

git clone https://github.com/verdaccio/docker-examples.git verdaccio-docker-examples
cd verdaccio-docker-examples/reverse_proxy/nginx/relative_path/
docker-compose build
docker-compose up

This starts Verdaccio instances at / (v4), /verdaccio/ (v4), and /verdacciov3/ (v3). They all look and operate fine.

However, the source code in the /verdaccio/ instance refers to assets using URLs beginning with /, rather than /verdaccio/ as specified in the url_prefix:

<script type="text/javascript" src="/-/static/manifest.ba207bfcf72b6ad80f79.js"></script><script type="text/javascript" src="/-/static/vendors.ba207bfcf72b6ad80f79.js"></script><script type="text/javascript" src="/-/static/main.ba207bfcf72b6ad80f79.js"></script></body>

When I access /verdaccio/, I see log entries from both the verdaccio_relative_path_v4 and verdaccio_relative_path_v4_root containers.

If I then disable the verdaccio_relative_path_v4_root container and refresh the browser, the /verdaccio/ page turns white, and the browser developer tools show these resources failed to load. The instance at /verdacciov3/ continues functioning unaffected.

why's this an issue?

In my use case, I need to confine Verdaccio completely to a subdirectory using url_prefix, so serving the static assets from the the root of the domain is unfortunately not feasible.

related issues

See: #10
See: verdaccio/verdaccio#1299, verdaccio/verdaccio#1297

Many thanks,
Braxton

@bsh-ableton
Copy link
Author

This is confirmed in more detail by verdaccio/verdaccio#1523, and it appears to be introduced by verdaccio/ui#122.

I can confirm that the resources load properly when I revert that change, or add ToReplaceByVerdaccio/ manually to the three imports in verdaccio-ui's static/index.html. Unfortunately, simply reverting isn't possible because that would reintroduce https://github.com/verdaccio/ui/issues/108.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant