Fix issue with last commit.

This commit is contained in:
comfyanonymous 2024-09-08 19:35:23 -04:00
parent 3ab3516e46
commit cbaac71bf5
1 changed files with 5 additions and 5 deletions

View File

@ -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