Enhance CORS configuration for better frontend integration

This commit is contained in:
Automated Action 2025-06-05 10:52:58 +00:00
parent 1a0c8dd221
commit d756051c4e
3 changed files with 6 additions and 7 deletions

View File

@ -194,9 +194,9 @@ The API has CORS (Cross-Origin Resource Sharing) enabled with the following conf
- http://localhost
- http://localhost:3000
- https://v0-ecommerce-app-build-swart.vercel.app
- *
- Allowed methods: GET, POST, PUT, DELETE, OPTIONS, PATCH
- Allowed headers: Content-Type, Authorization, Accept, Origin, X-Requested-With, X-CSRF-Token
- Exposed headers: Content-Length
- Allowed headers: Content-Type, Authorization, Accept, Origin, X-Requested-With, X-CSRF-Token, Access-Control-Allow-Credentials
- Exposed headers: Content-Length, Content-Type
- Credentials support: Enabled
- Max age for preflight requests: 600 seconds (10 minutes)

View File

@ -26,8 +26,7 @@ class Settings(BaseSettings):
CORS_ORIGINS: List[str] = [
"http://localhost",
"http://localhost:3000",
"https://v0-ecommerce-app-build-swart.vercel.app",
"*"
"https://v0-ecommerce-app-build-swart.vercel.app"
]
# Security settings

View File

@ -20,8 +20,8 @@ app.add_middleware(
allow_origins=settings.CORS_ORIGINS,
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
allow_headers=["Content-Type", "Authorization", "Accept", "Origin", "X-Requested-With", "X-CSRF-Token"],
expose_headers=["Content-Length"],
allow_headers=["Content-Type", "Authorization", "Accept", "Origin", "X-Requested-With", "X-CSRF-Token", "Access-Control-Allow-Credentials"],
expose_headers=["Content-Length", "Content-Type"],
max_age=600, # 10 minutes cache for preflight requests
)