trust proxy

This commit is contained in:
Anaïs Saraiva
2026-08-15 01:03:23 +02:00
parent f735c64e62
commit f1a8a05417
5 changed files with 88 additions and 19 deletions
+3 -1
View File
@@ -26,6 +26,7 @@ export async function handleUpload(
storage: Storage,
maxFileSize: number,
ttlMs: number,
publicBaseUrl?: string,
): Promise<Response> {
const contentType = req.headers.get("content-type");
const boundary = contentType ? getBoundary(contentType) : null;
@@ -77,8 +78,9 @@ export async function handleUpload(
expiresAt: new Date(Date.now() + ttlMs).toISOString(),
});
const url = publicBaseUrl ? `${publicBaseUrl}/${key}` : `/${key}`;
log("info", `upload ok id=${id} size=${size} name=${JSON.stringify(originalName)}`);
return json({ id, key, url: `/${key}`, originalName, size, protected: true });
return json({ id, key, url, originalName, size, protected: true });
} catch (err) {
await storage.delete(id);
await storage.deletePartial(id);