-
-
Notifications
You must be signed in to change notification settings - Fork 95
nginx relative path example depends on assets served from root #29
Description
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 upThis 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