Spaces:
Paused
Paused
Maksymilian Jankowski commited on
Commit Β·
b48c7f2
1
Parent(s): 6cbab81
deploy fix
Browse files
main.py
CHANGED
|
@@ -177,6 +177,14 @@ async def sync_supabase_user(request: SyncUserRequest, supabase_token: str = Dep
|
|
| 177 |
Sync a Supabase OAuth user (e.g., Google OAuth) with the backend database and return a backend JWT token.
|
| 178 |
"""
|
| 179 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
# Verify the Supabase token
|
| 181 |
logging.info(f"Verifying Supabase token for user sync")
|
| 182 |
supabase_user = verify_supabase_token(supabase_token)
|
|
@@ -866,8 +874,33 @@ async def place_order(request: PlaceOrderRequest, current_user: User = Depends(g
|
|
| 866 |
|
| 867 |
@app.get("/", tags=["Health"])
|
| 868 |
async def health_check():
|
| 869 |
-
"""
|
| 870 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 871 |
|
| 872 |
@app.get("/proxy/model", tags=["Proxy"])
|
| 873 |
async def proxy_model(url: str):
|
|
|
|
| 177 |
Sync a Supabase OAuth user (e.g., Google OAuth) with the backend database and return a backend JWT token.
|
| 178 |
"""
|
| 179 |
try:
|
| 180 |
+
# Check environment variables first
|
| 181 |
+
required_env_vars = ["SUPABASE_URL", "SUPABASE_KEY", "JWT_SECRET_KEY"]
|
| 182 |
+
missing_vars = [var for var in required_env_vars if not os.getenv(var)]
|
| 183 |
+
if missing_vars:
|
| 184 |
+
error_msg = f"Missing required environment variables: {', '.join(missing_vars)}"
|
| 185 |
+
logging.error(error_msg)
|
| 186 |
+
raise HTTPException(status_code=500, detail=error_msg)
|
| 187 |
+
|
| 188 |
# Verify the Supabase token
|
| 189 |
logging.info(f"Verifying Supabase token for user sync")
|
| 190 |
supabase_user = verify_supabase_token(supabase_token)
|
|
|
|
| 874 |
|
| 875 |
@app.get("/", tags=["Health"])
|
| 876 |
async def health_check():
|
| 877 |
+
return {"status": "ok", "message": "Service is running"}
|
| 878 |
+
|
| 879 |
+
# Add debug endpoint to check environment and connections
|
| 880 |
+
@app.get("/debug/env", tags=["Debug"])
|
| 881 |
+
async def debug_environment():
|
| 882 |
+
"""Debug endpoint to check environment variables and connections"""
|
| 883 |
+
debug_info = {
|
| 884 |
+
"environment_variables": {
|
| 885 |
+
"SUPABASE_URL": "β
Set" if os.getenv("SUPABASE_URL") else "β Missing",
|
| 886 |
+
"SUPABASE_KEY": "β
Set" if os.getenv("SUPABASE_KEY") else "β Missing",
|
| 887 |
+
"JWT_SECRET_KEY": "β
Set" if os.getenv("JWT_SECRET_KEY") else "β Missing",
|
| 888 |
+
"MESHY_API_KEY": "β
Set" if os.getenv("MESHY_API_KEY") else "β Missing",
|
| 889 |
+
"OPENAI_API_KEY": "β
Set" if os.getenv("OPENAI_API_KEY") else "β Missing",
|
| 890 |
+
"STRIPE_SECRET_KEY": "β
Set" if os.getenv("STRIPE_SECRET_KEY") else "β Missing"
|
| 891 |
+
},
|
| 892 |
+
"supabase_connection": "Unknown"
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
# Test Supabase connection
|
| 896 |
+
try:
|
| 897 |
+
# Simple test query to check connection
|
| 898 |
+
test_response = supabase.from_("User").select("user_id").limit(1).execute()
|
| 899 |
+
debug_info["supabase_connection"] = "β
Connected"
|
| 900 |
+
except Exception as e:
|
| 901 |
+
debug_info["supabase_connection"] = f"β Connection failed: {str(e)}"
|
| 902 |
+
|
| 903 |
+
return debug_info
|
| 904 |
|
| 905 |
@app.get("/proxy/model", tags=["Proxy"])
|
| 906 |
async def proxy_model(url: str):
|