mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 13:03:08 +00:00
Implement signed cdn urls
This commit is contained in:
1 parent
1d8e081fd8
commit
080b2c7d38
14 files changed
+279
-13
No files matched your search
@@ -35,6 +35,7 @@ import {
|
||||
emitEvent,
|
||||
getPermission,
|
||||
isTextChannel,
|
||||
resignUrl,
|
||||
uploadFile,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
@@ -199,16 +200,18 @@ router.get(
|
||||
? y.proxy_url
|
||||
: `https://example.org${y.proxy_url}`;
|
||||
|
||||
let pathname = new URL(uri).pathname;
|
||||
while (
|
||||
pathname.split("/")[0] != "attachments" &&
|
||||
pathname.length > 30
|
||||
) {
|
||||
pathname = pathname.split("/").slice(1).join("/");
|
||||
const url = new URL(uri);
|
||||
if (endpoint) {
|
||||
const newBase = new URL(endpoint);
|
||||
url.protocol = newBase.protocol;
|
||||
url.hostname = newBase.hostname;
|
||||
url.port = newBase.port;
|
||||
}
|
||||
if (!endpoint?.endsWith("/")) pathname = "/" + pathname;
|
||||
|
||||
y.proxy_url = `${endpoint == null ? "" : endpoint}${pathname}`;
|
||||
y.proxy_url = url.toString();
|
||||
|
||||
y.proxy_url = resignUrl(y.proxy_url);
|
||||
y.url = resignUrl(y.url);
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user