Images return 401 on publicly shared pages, even when uploaded directly to that page
Version: v0.95.0, self-hosted. I checked the v0.96.0 release notes and did not see anything covering attachment authorisation on share links, but I have not tested against it.
Summary
A publicly shared page serves its own HTML anonymously (200), but every attachment it references returns 401 Unauthorized. Anyone opening the share link without an account sees the page with all images broken.
This looks like #1194, which was closed on the basis that it happens when "the attachment was copied and pasted from another page". That does not apply here: every image in these pages was uploaded directly to the page that displays it, via POST /api/attachments/upload-file with that page's id. #1835 also reports share-link images failing (for images inside tables), so something in this area still appears broken.
Steps to reproduce
- Create a page.
- Upload an image directly to that page (not copied from elsewhere).
- Share the page publicly.
- Open the share link in a private window.
Expected
The image renders, as the page itself does.
Actual
The page renders; the image is broken.
GET /share/<shareId>/p/<slug> → 200
GET /api/files/<uuid>/<filename> → 401 {"message":"Unauthorized","statusCode":401}
GET /api/files/<uuid>/<filename> → 401 (with Referer set to the share page)No public attachment route appears to exist. These all return the SPA shell rather than the file:
GET /files/<uuid>/<filename> → 200 text/html (1667 bytes)
GET /api/attachments/<uuid>/<filename> → 200 text/html (1667 bytes)
GET /share/<shareId>/api/files/<uuid>/<filename> → 200 text/html (1667 bytes)Notes
The /api/files/<uuid>/<filename> URL form is Docmost's own: pages authored by hand in the editor produce the identical shape, and they break the same way on a share link.
Related: #1194 (closed), #1835 (open).
Source: docmost/docmost