Spaces:
Running
Running
refactor: redirect Cloudflare proxy setup logs and error messages to stderr
Browse files
cloudflare-proxy-setup.py
CHANGED
|
@@ -178,9 +178,9 @@ def main() -> int:
|
|
| 178 |
"Warning: CLOUDFLARE_PROXY_URL is set but CLOUDFLARE_PROXY_SECRET "
|
| 179 |
"is empty. Requests will succeed only if the deployed worker "
|
| 180 |
"was built without PROXY_SHARED_SECRET; otherwise you'll see "
|
| 181 |
-
"401 Unauthorized."
|
|
|
|
| 182 |
)
|
| 183 |
-
print(f"Using configured Cloudflare proxy: {existing_url}")
|
| 184 |
return 0
|
| 185 |
|
| 186 |
if not api_token:
|
|
@@ -230,7 +230,6 @@ def main() -> int:
|
|
| 230 |
|
| 231 |
proxy_url = f"https://{worker_name}.{subdomain}.workers.dev"
|
| 232 |
write_env(proxy_url, proxy_secret)
|
| 233 |
-
print(f"Cloudflare proxy ready: {proxy_url}")
|
| 234 |
return 0
|
| 235 |
except urllib.error.HTTPError as error:
|
| 236 |
detail = error.read().decode("utf-8", errors="replace")
|
|
@@ -240,12 +239,13 @@ def main() -> int:
|
|
| 240 |
"Use a Cloudflare API Token in CLOUDFLARE_WORKERS_TOKEN "
|
| 241 |
"(not a Global API Key, tunnel token, or worker secret). "
|
| 242 |
"For auto-setup, it should have account-level 'Workers Scripts: Edit'. "
|
| 243 |
-
"The setup can auto-discover your account; CLOUDFLARE_ACCOUNT_ID is not required."
|
|
|
|
| 244 |
)
|
| 245 |
-
print(f"Cloudflare proxy setup failed: HTTP {error.code} {detail}")
|
| 246 |
return 1
|
| 247 |
except Exception as error:
|
| 248 |
-
print(f"Cloudflare proxy setup failed: {error}")
|
| 249 |
return 1
|
| 250 |
|
| 251 |
|
|
|
|
| 178 |
"Warning: CLOUDFLARE_PROXY_URL is set but CLOUDFLARE_PROXY_SECRET "
|
| 179 |
"is empty. Requests will succeed only if the deployed worker "
|
| 180 |
"was built without PROXY_SHARED_SECRET; otherwise you'll see "
|
| 181 |
+
"401 Unauthorized.",
|
| 182 |
+
file=sys.stderr,
|
| 183 |
)
|
|
|
|
| 184 |
return 0
|
| 185 |
|
| 186 |
if not api_token:
|
|
|
|
| 230 |
|
| 231 |
proxy_url = f"https://{worker_name}.{subdomain}.workers.dev"
|
| 232 |
write_env(proxy_url, proxy_secret)
|
|
|
|
| 233 |
return 0
|
| 234 |
except urllib.error.HTTPError as error:
|
| 235 |
detail = error.read().decode("utf-8", errors="replace")
|
|
|
|
| 239 |
"Use a Cloudflare API Token in CLOUDFLARE_WORKERS_TOKEN "
|
| 240 |
"(not a Global API Key, tunnel token, or worker secret). "
|
| 241 |
"For auto-setup, it should have account-level 'Workers Scripts: Edit'. "
|
| 242 |
+
"The setup can auto-discover your account; CLOUDFLARE_ACCOUNT_ID is not required.",
|
| 243 |
+
file=sys.stderr,
|
| 244 |
)
|
| 245 |
+
print(f"Cloudflare proxy setup failed: HTTP {error.code} {detail}", file=sys.stderr)
|
| 246 |
return 1
|
| 247 |
except Exception as error:
|
| 248 |
+
print(f"Cloudflare proxy setup failed: {error}", file=sys.stderr)
|
| 249 |
return 1
|
| 250 |
|
| 251 |
|