fix(ui): rewrite image URLs to include proxy prefix when embedded #90
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_books!90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_fix_image_urls_proxy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fix broken image rendering for absolute URLs (e.g.
/img/foo.png) in markdown pages when hero_books is embedded inside hero_os at/hero_books/ui/. Standalone mode is unaffected.Related Issue
Closes lhumina_code/hero_os#69
Changes
crates/hero_books_ui/src/handlers.rs— server-side:rewrite_image_urls(html, base)now prefixes absolute paths with the proxy base derived fromX-Forwarded-Prefix;markdown_to_html(md, base)threads the base through;handler_pagepasses&baseinto both branches.crates/hero_books_app/src/components/library.rs— client-side: newrewrite_asset_urls(html)helper readsrpc::base_path(), strips trailing/uito derive the asset base, rewritessrc="/img/...→src="{asset_base}/img/.... No-op in standalone mode. Applied tomarkdown_to_htmloutput.crates/hero_books_app/src/components/page.rs— client-side:PageViewnow pipes server-renderedcontent_htmlthroughrewrite_asset_urls()so pre-rendered HTML also gets the prefix.Behavioural matrix
/img/foo.pngworks/img/foo.pngstill works (no rewrite)/hero_books/ui//img/foo.png404s/img/foo.png→/hero_books/img/foo.pnghttp://,https://)data:URIsTest Results
cargo build --release -p hero_books_ui -p hero_books_app— passes.cargo test --release -p hero_books_ui -p hero_books_app— passes (no failures).Caveats
/hero_books/uiincrates/hero_books_app/src/app.rs:94(when anIslandContextis present). Server-side path is dynamic viaX-Forwarded-Prefix.