From 4c554d5cc1493b908ccc4505c21c9bd020968eb1 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Fri, 20 Dec 2024 00:42:10 +0300 Subject: [PATCH 1/3] fix(nginx): _assets should rewrite to _static/sentry/dist Our default fallback, `_assets`, assumes we use a CDN which is not the case on self-hosted. This patch adds a stop-gap fix for front-end URLs asking for this path. Should fix #3479 and #3470. --- nginx.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nginx.conf b/nginx.conf index 32d9487f80..17e43f8563 100644 --- a/nginx.conf +++ b/nginx.conf @@ -98,6 +98,9 @@ http { location / { proxy_pass http://sentry; } + location /_assets/ { + proxy_pass http://sentry/_static/dist/sentry/; + } location /_static/ { proxy_pass http://sentry; proxy_hide_header Content-Disposition; From 94505dfd08e20e92d285f79aec3f5a3ab5358fed Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Fri, 20 Dec 2024 21:06:36 +0300 Subject: [PATCH 2/3] a test and a minor update --- _integration-test/test_run.py | 8 ++++++++ nginx.conf | 1 + 2 files changed, 9 insertions(+) diff --git a/_integration-test/test_run.py b/_integration-test/test_run.py index 2b5774832b..1ddbbbbf4a 100644 --- a/_integration-test/test_run.py +++ b/_integration-test/test_run.py @@ -80,6 +80,14 @@ def test_initial_redirect(): assert initial_auth_redirect.url == f"{SENTRY_TEST_HOST}/auth/login/sentry/" +def test_asset_internal_rewrite(): + """Tests whether we correctly map `/_assets/*` to `/_static/dist/sentry` as + we don't have a CDN setup in self-hosted.""" + response = httpx.get(f"{SENTRY_TEST_HOST}/_assets/entrypoints/app.js") + assert response.status_code == 200 + assert response.headers["Content-Type"] == "application/javascript" + + def test_login(client_login): client, login_response = client_login parser = BeautifulSoup(login_response.text, "html.parser") diff --git a/nginx.conf b/nginx.conf index 17e43f8563..94d7964d58 100644 --- a/nginx.conf +++ b/nginx.conf @@ -100,6 +100,7 @@ http { } location /_assets/ { proxy_pass http://sentry/_static/dist/sentry/; + proxy_hide_header Content-Disposition; } location /_static/ { proxy_pass http://sentry; From c785ef0c217bd01c79e4c39d72b547e6bfd4242e Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Fri, 20 Dec 2024 22:09:03 +0300 Subject: [PATCH 3/3] fix content type check --- _integration-test/test_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_integration-test/test_run.py b/_integration-test/test_run.py index 1ddbbbbf4a..d1c8f4547c 100644 --- a/_integration-test/test_run.py +++ b/_integration-test/test_run.py @@ -85,7 +85,7 @@ def test_asset_internal_rewrite(): we don't have a CDN setup in self-hosted.""" response = httpx.get(f"{SENTRY_TEST_HOST}/_assets/entrypoints/app.js") assert response.status_code == 200 - assert response.headers["Content-Type"] == "application/javascript" + assert response.headers["Content-Type"] == "text/javascript" def test_login(client_login):