bsure-api / scripts /test_cors.py
“mohansree14”
Deploy Bsure API with correct structure
af1d8cd
Raw History Blame Contribute Delete
1.03 kB
import requests
try:
print("Testing CORS preflight/headers...")
response = requests.options(
"http://localhost:8000/auth/register",
headers={
"Origin": "http://localhost:3000",
"Access-Control-Request-Method": "POST",
"Access-Control-Request-Headers": "content-type"
}
)
print(f"OPTIONS Status: {response.status_code}")
print(f"Access-Control-Allow-Origin: {response.headers.get('access-control-allow-origin')}")
print(f"Access-Control-Allow-Methods: {response.headers.get('access-control-allow-methods')}")
print("\nTesting POST request...")
response = requests.post(
"http://localhost:8000/auth/login",
json={"email": "test@example.com", "password": "password123"},
headers={"Origin": "http://localhost:3000"}
)
print(f"POST Status: {response.status_code}")
print(f"Access-Control-Allow-Origin: {response.headers.get('access-control-allow-origin')}")
except Exception as e:
print(f"Error: {e}")