Skip to content

Commit 23e36b3

Browse files
authored
Fix Access-Control-Expose-Headers for Flask (#2329)
* Fix Flask Expose Headers * add a test * switch to single quotes
1 parent 2568f90 commit 23e36b3

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

pygeoapi/flask_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
if CONFIG['server'].get('cors', False):
8787
try:
8888
from flask_cors import CORS
89-
CORS(APP, CORS_EXPOSE_HEADERS=['*'])
89+
CORS(APP, expose_headers='*')
9090
except ModuleNotFoundError:
9191
print('Python package flask-cors required for CORS support')
9292

tests/api/test_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ def test_apirules_active(config_with_rules, rules_api):
280280
assert response.status_code == 200
281281
response = flask_client.get(flask_prefix)
282282
assert response.status_code in (307, 308)
283+
# Ensure that the expose-headers are set regardless of
284+
# whether apirules are active or not
285+
assert response.headers['Access-Control-Expose-Headers'] == '*'
283286

284287
# Test links on landing page for correct URLs
285288
response = flask_client.get(flask_prefix, follow_redirects=True)
@@ -342,6 +345,9 @@ def test_apirules_inactive(config, api_):
342345
flask_client.application.url_for('pygeoapi.conformance')
343346
response = flask_client.get('/static/img/pygeoapi.png')
344347
assert response.status_code == 200
348+
# Ensure that the expose-headers are set regardless of
349+
# whether apirules are active or not
350+
assert response.headers['Access-Control-Expose-Headers'] == '*'
345351

346352
# Test trailing slashes
347353
response = flask_client.get('/')

0 commit comments

Comments
 (0)