Fix cookie expiration time zone (#408)

* Fix cookie expiration time zone

* Fix the loss of cross-domain cookies
This commit is contained in:
Wu Clan
2024-09-08 17:33:51 +08:00
committed by GitHub
parent 4f5c5c28e6
commit 1d956cace4
7 changed files with 39 additions and 20 deletions
@@ -209,11 +209,12 @@ def register_exception(app: FastAPI):
if settings.MIDDLEWARE_CORS:
@app.exception_handler(StandardResponseCode.HTTP_500)
async def cors_status_code_500_exception_handler(request, exc):
async def cors_custom_code_500_exception_handler(request, exc):
"""
跨域 500 异常处理
跨域自定义 500 异常处理
`Related issue <https://github.com/encode/starlette/issues/1175>`_
`Solution <https://github.com/fastapi/fastapi/discussions/7847#discussioncomment-5144709>`_
:param request:
:param exc:
@@ -244,7 +245,7 @@ def register_exception(app: FastAPI):
if origin:
cors = CORSMiddleware(
app=app,
allow_origins=['*'],
allow_origins=settings.CORS_ALLOWED_ORIGINS,
allow_credentials=True,
allow_methods=['*'],
allow_headers=['*'],