From e3b0402bb792c528a8b2fadd11d35604bafc0d7b Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Mon, 9 Sep 2024 01:04:03 -0400 Subject: [PATCH] Ignore origin domain when it's empty. --- server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index ccb8fe81..4f8053fc 100644 --- a/server.py +++ b/server.py @@ -88,9 +88,10 @@ def create_origin_only_middleware(): origin = request.headers['Origin'] host_domain = host.lower() origin_domain = urllib.parse.urlparse(origin).netloc.lower() - if host_domain != origin_domain: - logging.warning("WARNING: request with non matching host and origin {} != {}, returning 403".format(host_domain, origin_domain)) - return web.Response(status=403) + if len(host_domain) > 0 and len(origin_domain) > 0: + if host_domain != origin_domain: + logging.warning("WARNING: request with non matching host and origin {} != {}, returning 403".format(host_domain, origin_domain)) + return web.Response(status=403) if request.method == "OPTIONS": response = web.Response()