File size: 1,429 Bytes
fa85d00 ee09c9c fa85d00 c99086b fa85d00 c99086b ee09c9c c99086b fa85d00 ee09c9c fa85d00 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import os
from supabase import create_client, Client
import httpx
# Ensure these environment variables are set
url: str = os.environ.get("SUPABASE_URL", "").strip().strip("'").strip('"')
key: str = os.environ.get("SUPABASE_KEY", "").strip().strip("'").strip('"')
if not url or not key:
print("[-] CRITICAL: SUPABASE_URL or SUPABASE_KEY not set in environment.")
raise RuntimeError("Missing SUPABASE_URL or SUPABASE_KEY environment variables.")
if not url.startswith("https://"):
print(f"[-] CRITICAL: Invalid SUPABASE_URL format: {url}")
raise RuntimeError(f"SUPABASE_URL must start with 'https://'. Got: {url}")
print(f"[*] Raw URL repr: {repr(url)}") # Debug hidden characters
print(f"[*] Initializing Supabase Client with URL: {url[:15]}...{url[-5:]} (Masked)")
# --- CONNECTIVITY CHECK ---
try:
print(f"[*] Testing connectivity to {url}...")
# Supabase projects usually respond to /rest/v1/ or just base with 404 or 200
# We just want to check if DNS resolves.
with httpx.Client(timeout=5.0) as client:
resp = client.get(url)
print(f"[*] Connectivity Check Status: {resp.status_code}")
except Exception as e:
print(f"[-] CRITICAL: Connectivity Check Failed. DNS or Network Issue.")
print(f"[-] Error: {e}")
# We do not raise here to allow app to try anyway, but this log will be vital.
# --------------------------
supabase: Client = create_client(url, key)
|