Enhance CORS configuration for better frontend integration
This commit is contained in:
parent
1a0c8dd221
commit
d756051c4e
@ -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)
|
@ -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
|
||||
|
4
main.py
4
main.py
@ -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
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user