Relay POST /files uploads through the web proxy and peer relay

The direct proxy already forwards every /files method behind the sign-in
gate; the peer relay now allows POST /files beside /chat-uploads. Tests cover
the name header, body and refusal of other POST targets.
This commit is contained in:
2026-11-09 00:00:00 +00:00
parent 81460c4a4d
commit c600f1560c
3 changed files with 109 additions and 1 deletions
+3 -1
View File
@@ -17,6 +17,8 @@ const allowed = (path) =>
path === "/chat-uploads" ||
path.startsWith("/artifacts/") ||
path.startsWith("/updates/");
// Raw-body uploads: chat attachments and files stored into a home folder.
const postable = (path) => path === "/chat-uploads" || path === "/files";
export class PeerRelay extends PeerRegistry {
target(req, path) {
const parsed = new URL(req.url, "http://localhost");
@@ -45,7 +47,7 @@ export class PeerRelay extends PeerRegistry {
!target ||
!allowed(target.url.pathname) ||
!["GET", "HEAD", "POST"].includes(req.method) ||
(req.method === "POST" && target.url.pathname !== "/chat-uploads")
(req.method === "POST" && !postable(target.url.pathname))
) {
json(res, 404, { error: "Unsupported remote resource" });
return true;