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
|
||||||
- http://localhost:3000
|
- http://localhost:3000
|
||||||
- https://v0-ecommerce-app-build-swart.vercel.app
|
- https://v0-ecommerce-app-build-swart.vercel.app
|
||||||
- *
|
|
||||||
|
|
||||||
- Allowed methods: GET, POST, PUT, DELETE, OPTIONS, PATCH
|
- Allowed methods: GET, POST, PUT, DELETE, OPTIONS, PATCH
|
||||||
- Allowed headers: Content-Type, Authorization, Accept, Origin, X-Requested-With, X-CSRF-Token
|
- Allowed headers: Content-Type, Authorization, Accept, Origin, X-Requested-With, X-CSRF-Token, Access-Control-Allow-Credentials
|
||||||
- Exposed headers: Content-Length
|
- Exposed headers: Content-Length, Content-Type
|
||||||
|
- Credentials support: Enabled
|
||||||
- Max age for preflight requests: 600 seconds (10 minutes)
|
- Max age for preflight requests: 600 seconds (10 minutes)
|
@ -26,8 +26,7 @@ class Settings(BaseSettings):
|
|||||||
CORS_ORIGINS: List[str] = [
|
CORS_ORIGINS: List[str] = [
|
||||||
"http://localhost",
|
"http://localhost",
|
||||||
"http://localhost:3000",
|
"http://localhost:3000",
|
||||||
"https://v0-ecommerce-app-build-swart.vercel.app",
|
"https://v0-ecommerce-app-build-swart.vercel.app"
|
||||||
"*"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Security settings
|
# Security settings
|
||||||
|
4
main.py
4
main.py
@ -20,8 +20,8 @@ app.add_middleware(
|
|||||||
allow_origins=settings.CORS_ORIGINS,
|
allow_origins=settings.CORS_ORIGINS,
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
|
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
|
||||||
allow_headers=["Content-Type", "Authorization", "Accept", "Origin", "X-Requested-With", "X-CSRF-Token"],
|
allow_headers=["Content-Type", "Authorization", "Accept", "Origin", "X-Requested-With", "X-CSRF-Token", "Access-Control-Allow-Credentials"],
|
||||||
expose_headers=["Content-Length"],
|
expose_headers=["Content-Length", "Content-Type"],
|
||||||
max_age=600, # 10 minutes cache for preflight requests
|
max_age=600, # 10 minutes cache for preflight requests
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user