Clicking internal link to uploaded file redirects to home instead of opening it
Author: waerisCreated Aug 29, 2026Updated Sep 15, 2026
Labelstype/bug
Current Behavior
Bug Report
Current Behavior
Clicking on a direct in-post link to an uploaded file (e.g. an image link, <a href="https://example.com/assets/files/...jpg" class="UrlLink UrlLink--internal">) redirects the user to the forum's home page (/) instead of navigating to the file.
Opening the same link in a new tab (e.g. via "Open in new tab") works correctly and loads the image as expected — the issue only occurs on a direct in-app left-click.
Steps to Reproduce
- Upload an image to a post (via FoF Upload or core upload)
- The resulting link in the rendered post has class
UrlLink UrlLink--internal - Left-click directly on the image/link within the post
- Observe: instead of opening/viewing the image, the app redirects to the forum home page
- Right-click → "Open in new tab" on the same link works fine and loads the image directly
Expected Behavior
Clicking the link should either:
- Load/display the linked file (image), or
- At minimum, not redirect to an unrelated page (home)
Root Cause (found via investigation)
Formatter::isInternalUrl()invendor/flarum/core/src/Formatter/Formatter.phpmarks any same-host URL as internal (UrlLink--internal), including links to static uploaded files that have no corresponding Mithril route (e.g./assets/files/...).- The client-side handler in
js/src/forum/utils/routeInternalLinks.tstrusts this class without checking whether the path actually corresponds to a registered app route. - Since
/assets/files/...doesn't match any registered Mithril route,m.route.set()silently falls back to the default route (home), per the same mechanism described in the code's own comment about forums installed in a subdirectory.
Context
Steps to Reproduce
- Upload an image to a post (e.g. via FoF Upload or core upload)
- The resulting link in the rendered post has class
UrlLink UrlLink--internal - Left-click directly on the image/link within the post
- Observe that instead of opening/viewing the image, the app redirects to the forum home page
- Right-click → "Open in new tab" on the same link works fine and loads the image directly
Expected Behavior
Clicking the link should either load/display the linked file (image), or at minimum not redirect to an unrelated page (home).
Screenshots
No response
Environment
- Flarum version: x.y.z
- Website URL: http://example.com
- Webserver: [e.g. apache, nginx]
- Hosting environment: [e.g. shared, vps]
- PHP version: x.y.z
- Database: [e.g. MySQL 8.4.11, MariaDB 10.11.2, PostgreSQL 16.1, SQLite 3.45]
- Browser: [e.g. chrome 67, safari 11]
Output of php flarum info
Output of "php flarum info", run this in terminal in your Flarum directory.Possible Solution
No response
Additional Context
No response
Source: flarum/framework