mirror of
https://github.com/ZSCGR/CloudFlare-ImgBed.git
synced 2026-08-16 05:33:44 +08:00
22 lines
910 B
JavaScript
22 lines
910 B
JavaScript
import { errorHandling, telemetryData } from "./utils/middleware";
|
|
export async function onRequestPost(context) { // Contents of context object
|
|
const {
|
|
request, // same as existing Worker API
|
|
env, // same as existing Worker API
|
|
params, // if filename includes [id] or [[path]]
|
|
waitUntil, // same as ctx.waitUntil in existing Worker API
|
|
next, // used for middleware or to fetch assets
|
|
data, // arbitrary space for passing data between middlewares
|
|
} = context;
|
|
const clonedRequest = request.clone();
|
|
await errorHandling(context);
|
|
telemetryData(context);
|
|
const url = new URL(clonedRequest.url);
|
|
const response = fetch('https://telegra.ph/' + url.pathname + url.search, {
|
|
method: clonedRequest.method,
|
|
headers: clonedRequest.headers,
|
|
body: clonedRequest.body,
|
|
});
|
|
return response;
|
|
}
|