From da6cd017fa3a90d34ea25f886d1e5361d6437eee Mon Sep 17 00:00:00 2001 From: urec56 Date: Fri, 7 Jun 2024 12:14:11 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BC=D0=B8=D0=B4=D0=BB=D0=B2=D0=B0=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index ad3489a..dece154 100644 --- a/app/main.py +++ b/app/main.py @@ -23,7 +23,15 @@ app.include_router(user_router) app.include_router(image_router) origins = ["http://localhost:5173"] -headers = ["Content-Type", "Set-Cookie", "Access-Control-Allow-Headers", "Authorization", "Accept", "Access-Control-Allow-Origin"] +headers = [ + "Content-Type", + "Set-Cookie", + "Access-Control-Allow-Headers", + "Authorization", + "Accept", + "Access-Control-Allow-Origin", + "Sec-WebSocket-Protocol" +] app.add_middleware( CORSMiddleware, @@ -38,9 +46,9 @@ app.mount("/static", StaticFiles(directory="app/static"), name="static") class AddHeaderMiddleware(BaseHTTPMiddleware): async def dispatch(self, request: Request, call_next): - logging.critical(request.headers) + logging.critical(f"Запрос \n{request.headers}") response = await call_next(request) - logging.critical(response.headers) + logging.critical(f"Ответ \n {response.headers}") if "Sec-Websocket-Protocol" in request.headers: raise ValueError(request.headers["Sec-Websocket-Protocol"]) response.headers["Sec-Websocket-Protocol"] = request.headers["Sec-Websocket-Protocol"]