summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-08-25 06:50:34 +0200
committerTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-08-25 06:50:34 +0200
commit1bf2424033185eaf9ff1f97b5403142f5b098df0 (patch)
tree0fffa4360c9089fd1a51278d8ddaa4e615cd5766 /src/api
parentMerge pull request #1197 from DEVTomatoCake/feat/improve-no-authorization-routes (diff)
downloadserver-ts-1bf2424033185eaf9ff1f97b5403142f5b098df0.tar.xz
Remove auth requirement & fix image path
Diffstat (limited to 'src/api')
-rw-r--r--src/api/middlewares/Authentication.ts2
-rw-r--r--src/api/middlewares/ImageProxy.ts4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts

index ffefee8fb..187859085 100644 --- a/src/api/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts
@@ -54,6 +54,8 @@ export const NO_AUTHORIZATION_ROUTES = [ /GET \/guilds\/\d+\/widget\.(json|png)/, // Connections /POST \/connections\/\w+\/callback/, + // Image proxy + /GET \/imageproxy\/[A-Za-z0-9+/]\/\d+x\d+\/.+/ ]; export const API_PREFIX = /^\/api(\/v\d+)?/; diff --git a/src/api/middlewares/ImageProxy.ts b/src/api/middlewares/ImageProxy.ts
index 537c5da17..d1d0faa79 100644 --- a/src/api/middlewares/ImageProxy.ts +++ b/src/api/middlewares/ImageProxy.ts
@@ -67,7 +67,7 @@ export async function ImageProxy(req: Request, res: Response) { if (!crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(path[0]))) throw new Error("Invalid signature"); } catch { - console.log("Invalid signature, expected " + hash + " got " + path[0]); + console.log("[ImageProxy] Invalid signature, expected " + hash + " but got " + path[0]); res.status(403).send("Invalid signature"); return; } @@ -75,7 +75,7 @@ export async function ImageProxy(req: Request, res: Response) { const abort = new AbortController(); setTimeout(() => abort.abort(), 5000); - const request = await fetch(path.slice(2).join("/"), { + const request = await fetch("https://" + path.slice(2).join("/"), { headers: { "User-Agent": "SpacebarImageProxy/1.0.0 (https://spacebar.chat)", },