Issue-body images render broken in the panel drawer #42
Labels
No labels
bug
docs
enhancement
good first issue
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pedromcaraujo/forge#42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Images embedded in an issue body render as a broken-image icon (plus the linked alt-text) in the panel drawer's issue view.
Cause
Forgejo's
/api/v1/markdownAPI renders image attachments as root-relative HTML, e.g.:The drawer injects that HTML, but it is served from the launcher origin — not Forgejo — so
/attachments/…resolves against the launcher and 404s. Both the wrapping<a>and the<img>point at the wrong host.Fix
Post-process the rendered HTML in the panel sidecar (
web/panel.py) before returning it:<img src="/…">to route through a new authenticated sidecar proxy (/panel/<channel>/attachment?path=…), so private-repo images load without depending on the browser holding a live Forgejo session.<a href="/…">links to the Forgejo base URL so they open upstream.The proxy restricts fetches to Forgejo-internal attachment/media paths (guards against SSRF / open-proxy abuse of the token) and caps buffered size.
Reopening — the first fix (#43) didn't resolve this.
It assumed Forgejo's
/markdownAPI emits root-relative attachment URLs (src="/attachments/…") and only rewrote those. But this instance emits fully absolute URLs, e.g.:so
_rewrite_urlsmatched nothing, the browser fetched the attachment cross-origin, and — since attachments are auth-gated (verified: 404 without token, 200 with) — it failed.The sidecar proxy itself works (
/panel/<ch>/attachmentreturns 200 image/png with the token). The follow-up widens the<img>/<a>rewrite to also catch absolute URLs pointing at the Forgejo base and strip them to the internal path before routing through the proxy.Fixed and deployed to nix-dev (forge
24f4ed9). Verified live against Xloora/xloora#158: the panel now serves<img src="/panel/xloora/attachment?path=…">and that proxy path returns200 image/png. Leaving open for you to close.