Skip to content

Commit

Permalink
cors: fix some http response error not being catched by cors decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
Axolotle committed Nov 8, 2023
1 parent 20d3b82 commit 924fd78
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion moulinette/interfaces/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,11 @@ def __init__(self, routes={}, actionsmap=None, allowed_cors_origins=[]):

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
Expand Down

0 comments on commit 924fd78

Please sign in to comment.