Sorasaki Hina
Sorasaki Hina
CDCloudflare Developers
Created by Sorasaki Hina on 5/18/2024 in #workers-help
sending video
hi so I have a large db of mixed img and vid, and Im currently trying to send the randomly seleced media to the user, when I got an img the server sent everything fine, but when I got vid the servers tries to fetch the domain again which gave a random media (img/vid), is there any way to prevent this?
export default {
async fetch(request, env) {
const url = "db";
const response = await fetch(url);
const { contentType, result } = await gatherResponse(response);
const data = result;

// gatherResponse returns both content-type & response body as a string
async function gatherResponse(response) {
const { headers } = response;
const contentType = headers.get("content-type") || "";
return { contentType, result: await response.json() };
}

let ur2l = data[Math.floor(Math.random() * data.length)]

const aa = await fetch(ur2l.split("|")[2])
const resp = new Response((await aa.arrayBuffer()), {headers: { "content-type": aa.headers.get("content-type") || "no"}})

resp.headers.append("X-fetchedurl", ur2l.split("|")[2])
resp.headers.append("X-fetchedurlid", ur2l.split("|")[1])
resp.headers.append("X-fetchedurlname", ur2l.split("|")[0])
return resp;
}
}
export default {
async fetch(request, env) {
const url = "db";
const response = await fetch(url);
const { contentType, result } = await gatherResponse(response);
const data = result;

// gatherResponse returns both content-type & response body as a string
async function gatherResponse(response) {
const { headers } = response;
const contentType = headers.get("content-type") || "";
return { contentType, result: await response.json() };
}

let ur2l = data[Math.floor(Math.random() * data.length)]

const aa = await fetch(ur2l.split("|")[2])
const resp = new Response((await aa.arrayBuffer()), {headers: { "content-type": aa.headers.get("content-type") || "no"}})

resp.headers.append("X-fetchedurl", ur2l.split("|")[2])
resp.headers.append("X-fetchedurlid", ur2l.split("|")[1])
resp.headers.append("X-fetchedurlname", ur2l.split("|")[0])
return resp;
}
}
1 replies
CDCloudflare Developers
Created by Sorasaki Hina on 3/11/2024 in #general-help
cloudflare tunnel issue
Hello does any1 know how to expose my proxy using cloudflared? (the proxy server ran at port 808) The proxy can only support http and ran using CCPROXY settedup
31 replies