Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cors headers #171

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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