Skip to content

Commit

Permalink
Fix issue with last commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Sep 8, 2024
1 parent 3ab3516 commit cbaac71
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ async def cors_middleware(request: web.Request, handler):
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']
Expand All @@ -97,6 +92,11 @@ async def origin_only_middleware(request: web.Request, handler):
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
Expand Down

0 comments on commit cbaac71

Please sign in to comment.