Full CORS permissive mode and debug logger
This commit is contained in:
21
app/main.py
21
app/main.py
@@ -31,19 +31,20 @@ def create_application() -> FastAPI:
|
||||
# Mount Static Files
|
||||
application.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||
|
||||
# Set up CORS
|
||||
origins = [
|
||||
"https://articulateusercontent.com",
|
||||
"https://ai-gateway.ldex.dev",
|
||||
"http://localhost:8000",
|
||||
"http://127.0.0.1:8000",
|
||||
]
|
||||
# Debug Logger Middleware
|
||||
@application.middleware("http")
|
||||
async def log_requests(request: Request, call_next):
|
||||
print(f"DEBUG: Incoming {request.method} {request.url}")
|
||||
print(f"DEBUG: Origin: {request.headers.get('origin')}")
|
||||
response = await call_next(request)
|
||||
print(f"DEBUG: Status Code: {response.status_code}")
|
||||
return response
|
||||
|
||||
# Set up fully permissive CORS for maximum compatibility
|
||||
application.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_origin_regex=r"https://.*\.articulateusercontent\.com",
|
||||
allow_credentials=True,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=False,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
expose_headers=["*"],
|
||||
|
||||
Reference in New Issue
Block a user