somratpro commited on
Commit
5131b7d
·
1 Parent(s): 149646c

debug: add host match logging

Browse files
Files changed (1) hide show
  1. cloudflare-proxy.js +11 -8
cloudflare-proxy.js CHANGED
@@ -46,18 +46,21 @@ if (PROXY_URL) {
46
  const isInternal =
47
  normalized === "localhost" ||
48
  normalized === "127.0.0.1" ||
 
 
49
  normalized.endsWith(".hf.space") ||
50
  normalized.endsWith(".huggingface.co") ||
51
  normalized === "huggingface.co";
52
 
53
- if (PROXY_ALL) {
54
- return !isInternal;
55
- }
56
-
57
- return BLOCKED_DOMAINS.some(
58
- (domain) =>
59
- normalized === domain || normalized.endsWith(`.${domain}`),
60
  );
 
 
 
 
 
 
61
  };
62
 
63
  const patch = (original, originalModuleName) => {
@@ -74,7 +77,7 @@ if (PROXY_URL) {
74
  hostname = options.hostname;
75
  path = options.pathname + options.search;
76
  headers = options.headers || {};
77
- } else {
78
  hostname =
79
  options.hostname ||
80
  (options.host ? String(options.host).split(":")[0] : "");
 
46
  const isInternal =
47
  normalized === "localhost" ||
48
  normalized === "127.0.0.1" ||
49
+ normalized === "::1" ||
50
+ normalized === "0.0.0.0" ||
51
  normalized.endsWith(".hf.space") ||
52
  normalized.endsWith(".huggingface.co") ||
53
  normalized === "huggingface.co";
54
 
55
+ const should = PROXY_ALL ? !isInternal : BLOCKED_DOMAINS.some(
56
+ (domain) => normalized === domain || normalized.endsWith(`.${domain}`)
 
 
 
 
 
57
  );
58
+
59
+ if (DEBUG && should && normalized !== proxy.hostname) {
60
+ log(`[cloudflare-proxy] Host match: ${normalized}`);
61
+ }
62
+
63
+ return should;
64
  };
65
 
66
  const patch = (original, originalModuleName) => {
 
77
  hostname = options.hostname;
78
  path = options.pathname + options.search;
79
  headers = options.headers || {};
80
+ } else if (options && typeof options === "object") {
81
  hostname =
82
  options.hostname ||
83
  (options.host ? String(options.host).split(":")[0] : "");