trust proxy
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user