Add forwarder_hosts config to scope upstream forwarder routing per host

This commit is contained in:
Mohammad Amin jahani
2026-05-10 14:58:54 +03:00
parent ea1b4a93f8
commit 931753e9f0
6 changed files with 71 additions and 2 deletions
+3 -1
View File
@@ -38,7 +38,9 @@ export default {
}
const upstreamUrl = (env && env.UPSTREAM_FORWARDER_URL) || "";
if (upstreamUrl) {
// f === 1: forward; f === 0: skip; missing: legacy client → forward (compat).
const wantForward = (req.f === 1) || (req.f === undefined);
if (upstreamUrl && wantForward) {
const upstreamResp = await forwardViaUpstream(req, env, upstreamUrl);
if (upstreamResp) return upstreamResp;
// fall through to direct fetch only when fail-mode is open
+3 -1
View File
@@ -105,7 +105,7 @@ function _buildWorkerPayload(req) {
}
}
return {
var out = {
u: req.u,
m: (req.m || "GET").toUpperCase(),
h: headers,
@@ -113,6 +113,8 @@ function _buildWorkerPayload(req) {
ct: req.ct || null,
r: req.r !== false
};
if (typeof req.f === "number") out.f = req.f;
return out;
}
function doGet(e) {