From ab30c54b176892e05772818e2ded73f684908c21 Mon Sep 17 00:00:00 2001 From: a76yyyy Date: Fri, 16 Feb 2024 19:26:28 +0800 Subject: [PATCH] =?UTF-8?q?Bugfix(web):=20=F0=9F=90=9B=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=9B=B4=E6=96=B0=E8=AE=A2=E9=98=85=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ip:port 登录且设置 domain 环境变量时会导致公共模板更新订阅时跨域验证失败 fix qd-today/qd#502 --- web/handlers/subscribe.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/handlers/subscribe.py b/web/handlers/subscribe.py index 1141f69562d..655b7d06d36 100644 --- a/web/handlers/subscribe.py +++ b/web/handlers/subscribe.py @@ -56,9 +56,13 @@ class SubscribeUpdatingHandler(BaseWebSocketHandler): updating = False updating_start_time = 0 - def check_origin(self, origin): + def check_origin(self, origin: str) -> bool: parsed_origin = urlparse(origin) - return parsed_origin.netloc.endswith(domain) + origin = parsed_origin.netloc.lower() + host: str = self.request.headers.get("Host", "") + logger_web_handler.debug("check_origin: %s, host: %s", origin, host) + + return origin.endswith(domain) or host.lower() == origin async def update(self, userid): SubscribeUpdatingHandler.updating = True