From cbaac71bf55c55e0bb4b878708fddece35073122 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sun, 8 Sep 2024 19:35:23 -0400 Subject: [PATCH] Fix issue with last commit. --- server.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index 4d78ee57..ccb8fe81 100644 --- a/server.py +++ b/server.py @@ -83,11 +83,6 @@ def create_cors_middleware(allowed_origin: str): def create_origin_only_middleware(): @web.middleware async def origin_only_middleware(request: web.Request, handler): - if request.method == "OPTIONS": - response = web.Response() - else: - response = await handler(request) - if 'Host' in request.headers and 'Origin' in request.headers: host = request.headers['Host'] origin = request.headers['Origin'] @@ -97,6 +92,11 @@ def create_origin_only_middleware(): 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() + else: + response = await handler(request) + return response return origin_only_middleware