This commit is contained in:
2026-08-10 18:39:29 +08:00
parent baf97b5fc5
commit 190cf54f0f
@@ -3,7 +3,7 @@ import json
import logging
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from fastapi import Request, Response
from fastapi import HTTPException, Request, Response
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
from app.config import settings
@@ -98,6 +98,9 @@ class RequestEncryptMiddleware(BaseHTTPMiddleware):
status_code=response.status_code,
headers={"X-Encrypted": "true", "Content-Type": "application/json"},
)
except HTTPException:
# 让 HTTPException(如 409 订单占用)正常传播,不被加密中间件拦截
raise
except Exception:
logger.exception("Request decryption failed")
return Response(