random接口维护

This commit is contained in:
MarSeventh
2024-09-09 08:51:17 +08:00
parent 6adc44da41
commit 8a0cd8ffda
+6 -2
View File
@@ -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
});
}