File size: 1,032 Bytes
af1d8cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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}")