- Backend: ?force=true on /proxy bypasses cache for fresh link fetch - Frontend: parse `se` param for live expiry countdown on download links - Frontend: show Refresh button when link expires in <6h, force-fetches fresh URL - Frontend: CliCommand component replaces Aria2Tip — wget/curl/aria2 tabs, persists selection in localStorage - Frontend: RecentlyViewed component — localStorage, shows active countdown or expired state - Frontend: FileSize shown alongside arch if returned by Microsoft CDN Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
const ALLOWED_HOSTS = [
|
|
"www.microsoft.com",
|
|
"vlscppe.microsoft.com",
|
|
"ov-df.microsoft.com",
|
|
];
|
|
|
|
export default {
|
|
async fetch(request) {
|
|
const url = new URL(request.url);
|
|
|
|
// Target host comes from the ?host= param; path+search are forwarded as-is
|
|
const targetHost = url.searchParams.get("host");
|
|
if (!targetHost || !ALLOWED_HOSTS.includes(targetHost)) {
|
|
return new Response(JSON.stringify({ error: "Invalid or missing host parameter" }), {
|
|
status: 400,
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
}
|
|
|
|
url.searchParams.delete("host");
|
|
url.hostname = targetHost;
|
|
url.protocol = "https:";
|
|
url.port = "";
|
|
|
|
const upstreamRequest = new Request(url.toString(), {
|
|
method: request.method,
|
|
headers: {
|
|
"User-Agent": request.headers.get("User-Agent") || "Mozilla/5.0",
|
|
"Referer": request.headers.get("Referer") || "",
|
|
"Accept": request.headers.get("Accept") || "application/json",
|
|
},
|
|
});
|
|
|
|
const upstream = await fetch(upstreamRequest);
|
|
|
|
return new Response(upstream.body, {
|
|
status: upstream.status,
|
|
headers: {
|
|
"Content-Type": upstream.headers.get("Content-Type") || "application/json",
|
|
"Access-Control-Allow-Origin": "*",
|
|
},
|
|
});
|
|
},
|
|
};
|