#5887·verdaccio

[Bug]: CSS assets fail to load when url_prefix is configured (dynamic imports ignore prefix)

Author: lerchc-bpkCreated May 21, 2026Updated Jul 10, 2026
Labelsissue_needs_triage

What happened?

Description

When setting url_prefix in the configuration (e.g., url_prefix: /js/), the web UI fails to load CSS files that are dynamically imported by JavaScript chunks.

Steps to reproduce

  1. Set url_prefix: /js/ in config.yaml
  2. Access the UI at https://verdaccio.example.com/js/

Expected behavior

All CSS assets load correctly from /js/-/static/filename.css.

Actual behavior

The HTML and initial JS load fine, but dynamically imported CSS files are requested at /-/static/filename.css (without the /js/ prefix), resulting in 404 errors and broken styling.

Root cause

In packages/plugins/ui-theme/vite.config.mjs, the Vite base option is hardcoded at build time:

javascript
base: command === 'build' ? '/-/static/' : '/',

This means all dynamic asset imports resolved by the Vite/Rolldown runtime use the absolute path /-/static/ regardless of the user's url_prefix configuration.

The static HTML template correctly prepends the url_prefix to asset paths (via getManifestValue in packages/middleware/src/middlewares/web/utils/manifest.ts), and the <base href> tag is also set correctly. However, dynamic import() calls within JS chunks resolve CSS paths using the build-time hardcoded /-/static/ base, completely bypassing the runtime url_prefix.

Suggested fix

Use a relative base path in the Vite config so that dynamic imports resolve relative to the document (and thus respect the <base href> tag set by the server):

javascript
base: command === 'build' ? '' : '/',

Or alternatively, leverage Vite's __vite_public_path__ runtime variable to inject the correct base path dynamically from window.__VERDACCIO_BASENAME_UI_OPTIONS.base.

Environment

  • Verdaccio version: 6.x (current main branch)
  • Configuration: url_prefix: /js/ (reproducible with any non-root prefix)

Version

6.x (Stable)

Version details

6.3.2

Output server log info

bash

Node.js Version

24.x.x (LTS)

Package manager

npm

Operating system

linux

Using reverse proxy

  • I am using a reverse proxy

Relevant log output

bash

Have I checked other issues?

  • I have searched existing issues