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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user