Skip to content

Commit

Permalink
Bugfix(web): 🐛 修复更新订阅跨域验证失败
Browse files Browse the repository at this point in the history
ip:port 登录且设置 domain 环境变量时会导致公共模板更新订阅时跨域验证失败

fix #502
  • Loading branch information
a76yyyy committed Feb 16, 2024
1 parent 0859366 commit ab30c54
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions web/handlers/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ab30c54

Please sign in to comment.