Skip to content

Commit

Permalink
Ignore origin domain when it's empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Sep 9, 2024
1 parent 967867d commit e3b0402
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ async def origin_only_middleware(request: web.Request, handler):
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()
Expand Down

0 comments on commit e3b0402

Please sign in to comment.