Fix: Removed redundant FastAPI CORS to prevent duplicate headers
This commit is contained in:
14
app/main.py
14
app/main.py
@@ -1,5 +1,5 @@
|
|||||||
from fastapi import FastAPI, Request
|
from fastapi import FastAPI, Request
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
# from fastapi.middleware.cors import CORSMiddleware
|
||||||
from slowapi import _rate_limit_exceeded_handler
|
from slowapi import _rate_limit_exceeded_handler
|
||||||
from slowapi.errors import RateLimitExceeded
|
from slowapi.errors import RateLimitExceeded
|
||||||
|
|
||||||
@@ -40,17 +40,7 @@ def create_application() -> FastAPI:
|
|||||||
print(f"DEBUG: Status Code: {response.status_code}")
|
print(f"DEBUG: Status Code: {response.status_code}")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Set up fully permissive CORS for maximum compatibility
|
# Set up Rate Limiter (CORS is handled by Caddy at the edge)
|
||||||
application.add_middleware(
|
|
||||||
CORSMiddleware,
|
|
||||||
allow_origins=["*"],
|
|
||||||
allow_credentials=False,
|
|
||||||
allow_methods=["*"],
|
|
||||||
allow_headers=["*"],
|
|
||||||
expose_headers=["*"],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set up Rate Limiter
|
|
||||||
application.state.limiter = limiter
|
application.state.limiter = limiter
|
||||||
|
|
||||||
@application.exception_handler(RateLimitExceeded)
|
@application.exception_handler(RateLimitExceeded)
|
||||||
|
|||||||
Reference in New Issue
Block a user