mirror of
https://github.com/denuitt1/mhr-cfw.git
synced 2026-05-18 23:54:35 +03:00
Add forwarder_hosts config to scope upstream forwarder routing per host
This commit is contained in:
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user