Skip to content

Commit

Permalink
Fix: Cross origin websockets not allowed (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansen authored Aug 22, 2023
1 parent 49cdce4 commit dbc3884
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 @@ -12,13 +12,13 @@
import time
import traceback
from typing import Any, Dict
from urllib.parse import quote
from urllib.parse import quote, urlparse

import aiohttp
from tornado import httputil
from tornado.web import Application

from config import proxies
from config import proxies, domain

from .base import *

Expand Down Expand Up @@ -57,6 +57,10 @@ class SubscribeUpdatingHandler(BaseWebSocketHandler):
updating = False
updating_start_time = 0

def check_origin(self, origin):
parsed_origin = urlparse(origin)
return parsed_origin.netloc.endswith(domain)

async def update(self, userid):
SubscribeUpdatingHandler.updating = True
SubscribeUpdatingHandler.updating_start_time = int(time.time())
Expand Down

0 comments on commit dbc3884

Please sign in to comment.