Repository navigation
fix(hub): make inline markdown image URLs absolute when caching remote notes - #1258
Closed
luoliguang wants to merge 1 commit into
Closed
luoliguang wants to merge 1 commit into
luoliguang wants to merge 1 commit into
Conversation
…e notes The RecommandJob already rewrites attachment paths to absolute URLs, but inline images embedded directly in note content (markdown `![]()` syntax and HTML `<img>` tags) were left as relative `/api/file/…` paths. When the hub renders those cached notes the viewer's browser resolves the relative paths against the viewer's own server, which has no token for the remote site's files → 401 Unauthorized for every inline image. Fix: after rewriting attachments, also rewrite relative `/api/file/` references in the content string to include the remote site's origin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Images embedded inline in note content (markdown
![]()syntax or HTML<img>tags) show as 401 Unauthorized when viewed in the Hub recommend tab.Example console errors:
Root cause
RecommandJobalready rewritesattachments[].pathto absolute URLs:path: `${url.origin}${a.path}`But inline images in the
contentmarkdown string are not rewritten. When the hub renders the cached note, the viewer's browser resolves/api/file/…against the viewer's own server — which has no token for the remote site's files.Fix
After rewriting attachments, also rewrite relative
/api/file/references in thecontentstring:Steps to reproduce