Spaces:
Configuration error
Configuration error
Download worker/src/forward.ts from UUUZCX/video-optimizer-bot: direct link, hf CLI and curl.
- Browser
- Download file 772 Bytes
-
https://huggingface.co/spaces/UUUZCX/video-optimizer-bot/resolve/main/worker/src/forward.ts
- Command line
-
hf download hf://spaces/UUUZCX/video-optimizer-bot/worker/src/forward.ts
-
curl -L -o forward.ts https://huggingface.co/spaces/UUUZCX/video-optimizer-bot/resolve/main/worker/src/forward.ts
772 Bytes
| import type { Env } from "./security"; | |
| export async function forwardToLocalBackend(request: Request, env: Env): Promise<Response> { | |
| const body = await request.arrayBuffer(); | |
| const response = await fetch(env.WORKER_FORWARD_URL, { | |
| method: "POST", | |
| headers: { | |
| "content-type": request.headers.get("content-type") || "application/json", | |
| "x-worker-secret": env.WORKER_SHARED_SECRET, | |
| "x-telegram-bot-api-secret-token": request.headers.get("x-telegram-bot-api-secret-token") || "" | |
| }, | |
| body, | |
| redirect: "manual" | |
| }); | |
| if (!response.ok) { | |
| console.error(JSON.stringify({ event: "forward_failed", status: response.status })); | |
| return new Response("forward failed", { status: 502 }); | |
| } | |
| return new Response("ok", { status: 200 }); | |
| } | |