From 0b66bae39759a5553d8ce46131dca3026325097b Mon Sep 17 00:00:00 2001
From: Roman Sergienko <romasergienko@outlook.com>
Date: Fri, 04 Dec 2026 11:19:03 +0000
Subject: [PATCH] Fix RP action upload response handling
---
web/auth.py | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/web/auth.py b/web/auth.py
index 114c076..b6dae94 100644
--- a/web/auth.py
+++ b/web/auth.py
@@ -101,9 +101,27 @@
"/miniapp",
"/miniapp/login",
) or request.path.startswith("/static")
+
+ # Для API запросов возвращаем JSON вместо редиректа
+ is_api = request.path.startswith("/api/")
+
if request["user"] is None and not public:
+ if is_api:
+ return web.json_response({"ok": False, "msg": "Не авторизован."}, status=401)
raise web.HTTPFound("/login")
- return await handler(request)
+ try:
+ response = await handler(request)
+ except web.HTTPException as response:
+ if request.path.startswith("/miniapp") or request.path == "/auth/miniapp":
+ response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0"
+ response.headers["Pragma"] = "no-cache"
+ raise
+ if request.path.startswith("/miniapp") or request.path == "/auth/miniapp":
+ response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0"
+ response.headers["Pragma"] = "no-cache"
+ if request.path.startswith("/static/"):
+ response.headers["Cache-Control"] = "no-cache, must-revalidate, max-age=0"
+ return response
async def login_page(request) -> web.Response:
@@ -163,8 +181,8 @@
token,
max_age=SESS_TTL,
httponly=True,
- samesite="Lax",
- secure=base_url(request).startswith("https"),
+ samesite="None",
+ secure=True,
)
return resp
--
Gitblit v1.9.3