Skip to content

Commit

Permalink
Added CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
zarya committed Oct 3, 2023
1 parent 7b355b5 commit 9585b4c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions services/apiService.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ def decorated_function(*args, **kwargs):
def auth_before_request():
if request.path.startswith('/docs') or request.path.startswith('/swagger') or request.path.startswith('/metrics'):
return None
if request.method == "OPTIONS":
res = Response()
res.headers['X-Content-Type-Options'] = '*'
return res
if request.endpoint and 'static' not in request.endpoint:
view_function = apiService.view_functions[request.endpoint]
if hasattr(view_function, 'view_class'):
Expand Down Expand Up @@ -253,6 +257,9 @@ def page_not_found(e):
@apiService.after_request
def apply_caching(response):
response.headers["HSS"] = str(config['hss']['OriginHost'])
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Access-Control-Allow-Methods"] = "GET,PUT,POST,DELETE,PATCH,OPTIONS"
response.headers["Access-Control-Allow-Headers"] = "Content-Type, Authorization, Content-Length, X-Requested-With, Provisioning-Key"
return response

@ns_apn.route('/<string:apn_id>')
Expand Down

0 comments on commit 9585b4c

Please sign in to comment.