Skip to content

fix: give /static/public module urls the deployment root path - #1263

Draft
maartenbreddels wants to merge 1 commit into
masterfrom
fix/versioned-url-root-path
Draft

maartenbreddels wants to merge 1 commit into
masterfrom
fix/versioned-url-root-path

Conversation

@maartenbreddels

Copy link
Copy Markdown
Contributor

An app served under a path prefix loads its ES modules from the wrong url.

Problem

When solara runs under a root path such as /myapp, a module defined with ipyvue.define_module(name, url="/static/public/x.mjs") (or with ipyreact) is preloaded and imported from /static/public/x.mjs, outside the app. versioned_url() adds the content hash, but not the root path. The browser gets a 404 and the module never loads.

Change

versioned_url() now puts settings.main.root_path in front of urls under /static/public. The hash still comes from the file behind the unprefixed path, and a url that already has a query string keeps it. External and protocol-relative urls stay as they are.

Validation

A new test, test_versioned_url_root_path, covers the prefix, an existing query string, and external urls. The existing versioned_url tests still pass (3 passed).

Gaps

root_path is only set by the starlette server, from the first request. Under flask, urls still get no prefix, as before.

Align results

Caution

/align was not run on this change: it is a small bug fix found during the work on #1179.

Crossreview results

Caution

/crossreview was not run on this change: a 4-line fix with a direct test.

🤖 Generated with Claude Code

versioned_url() returned /static/public/... without the root path, so an app
served under a prefix such as /myapp preloaded and imported its ES modules
from the wrong url (define_module with a url, in both the page's
modulepreload and the Module widget). External urls stay as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch had an error being deployed

1 failed deployment
fix/versioned-url-root-path - solara-stable PR #1263 — bff126c5 Deployed Oct 26, 2026 by maartenbreddels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant