mirror of
https://github.com/ZSCGR/CloudFlare-ImgBed.git
synced 2026-08-13 04:03:42 +08:00
+11
-1
@@ -33,10 +33,20 @@ export async function onRequest(context) {
|
|||||||
randomUrl = protocol + '//' + domain + randomPath;
|
randomUrl = protocol + '//' + domain + randomPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if param 'type' is set to 'img', return the image
|
||||||
|
if (randomType === 'img') {
|
||||||
|
// Return an image response
|
||||||
|
randomUrl = protocol + '//' + domain + ':' + port + randomPath;
|
||||||
|
return new Response(await fetch(randomUrl).then(res => res.blob()), {
|
||||||
|
headers: { 'Content-Type': 'image/jpeg' },
|
||||||
|
status: 200
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (resType == 'text') {
|
if (resType == 'text') {
|
||||||
return new Response(randomUrl, { status: 200 });
|
return new Response(randomUrl, { status: 200 });
|
||||||
} else {
|
} else {
|
||||||
return new Response(JSON.stringify({ url: randomUrl }), { status: 200 });
|
return new Response(JSON.stringify({ url: randomUrl }), { status: 200 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user