From 8a0cd8ffdac1e11434e6dc2bae28dc752e09e4e3 Mon Sep 17 00:00:00 2001 From: MarSeventh <1193267292@qq.com> Date: Mon, 9 Sep 2024 08:51:17 +0800 Subject: [PATCH] =?UTF-8?q?random=E6=8E=A5=E5=8F=A3=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/random.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/random.js b/functions/random.js index c5bbc1be..4e0ea10e 100644 --- a/functions/random.js +++ b/functions/random.js @@ -37,8 +37,12 @@ export async function onRequest(context) { if (randomType == 'img') { // Return an image response randomUrl = protocol + '//' + domain + ':' + port + randomPath; - return new Response(await fetch(randomUrl).then(res => res.blob()), { - headers: res.headers, + let contentType = 'image/jpeg'; + return new Response(await fetch(randomUrl).then(res => { + contentType = res.headers.get('content-type'); + res.blob(); + }), { + headers: contentType ? { 'Content-Type': contentType } : { 'Content-Type': 'image/jpeg' }, status: 200 }); }