Add CORS headers to /db?sql= query redirect (#2730)

Closes #2728
This commit is contained in:
wheelman 2026-05-24 09:51:13 +05:30 • committed by GitHub
commit b013aa1f7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -717,6 +717,17 @@ def test_cors(
assert "Access-Control-Max-Age" not in response.headers
def test_cors_query_redirect(app_client_with_cors):
# /db?sql= redirects to /db/-/query - the redirect itself needs CORS
# headers, otherwise browsers refuse to follow it cross-origin
response = app_client_with_cors.get(
"/fixtures?sql=select+1", follow_redirects=False
)
assert response.status == 302
assert response.headers["Location"] == "/fixtures/-/query?sql=select+1"
assert response.headers["Access-Control-Allow-Origin"] == "*"
@pytest.mark.parametrize(
"path",
(