cors: fix some http response error not being catched by cors decorator

This commit is contained in:
axolotle 2023-11-08 19:11:18 +01:00
parent 20d3b82340
commit 924fd7825e

View file

@ -734,7 +734,11 @@ class Interface:
def cors(callback):
def wrapper(*args, **kwargs):
r = callback(*args, **kwargs)
try:
r = callback(*args, **kwargs)
except HTTPResponse as e:
r = e
origin = request.headers.environ.get("HTTP_ORIGIN", "")
if origin and origin in self.allowed_cors_origins:
resp = r if isinstance(r, HTTPResponse) else response