Изменения мидлваре
This commit is contained in:
parent
d3bff12f40
commit
da6cd017fa
1 changed files with 11 additions and 3 deletions
14
app/main.py
14
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"]
|
||||
|
|
Loading…
Add table
Reference in a new issue