A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: use Referrer-Policy same-origin to fix Chrome 147+ Error code 5 on macOS (#9543)
Alireza Ghaffarifde52f1a0c84
diff --git a/marimo/_server/api/endpoints/assets.py b/marimo/_server/api/endpoints/assets.pyindex 3d217c4e22..943a35773f 100644--- a/marimo/_server/api/endpoints/assets.py+++ b/marimo/_server/api/endpoints/assets.py@@ -127,8 +127,15 @@ FILE_QUERY_PARAM_KEY = "file"# supplement the token-stripping redirect below by preventing any outbound# fetch from the HTML page from leaking a transiently-present access_token# via `Referer`, and by disabling MIME sniffing on the HTML response.+#+# Use "same-origin" instead of "no-referrer" to avoid Chrome 147+ on macOS+# treating localhost pages as private-network requests without a valid+# referrer, which triggers Local Network Access checks and "Error code 5".+# "same-origin" still prevents cross-origin referrer leakage while+# preserving the referrer for same-origin navigations.+# See: https://github.com/marimo-team/marimo/issues/9455_HTML_SECURITY_HEADERS: dict[str, str] = {- "Referrer-Policy": "no-referrer",+ "Referrer-Policy": "same-origin","X-Content-Type-Options": "nosniff",}diff --git a/tests/_server/api/endpoints/test_assets.py b/tests/_server/api/endpoints/test_assets.pyindex 93f2c023cc..24c7a292e0 100644--- a/tests/_server/api/endpoints/test_assets.py+++ b/tests/_server/api/endpoints/test_assets.py@@ -122,7 +122,7 @@ def test_index_strips_access_token_query_param(client: TestClient) -> None:response = client.get("/?access_token=fake-token", follow_redirects=False)assert response.status_code == 303, response.textassert response.headers["location"] == "/"- assert response.headers.get("referrer-policy") == "no-referrer"+ assert response.headers.get("referrer-policy") == "same-origin"assert response.headers.get("x-content-type-options") == "nosniff"# The session cookie must be set so the redirect target is authenticated# without the query param.@@ -206,7 +206,7 @@ def test_index_unauthenticated_redirect_preserves_next(def test_index_response_has_security_headers(client: TestClient) -> None:response = client.get("/", headers=token_header())assert response.status_code == 200, response.text- assert response.headers.get("referrer-policy") == "no-referrer"+ assert response.headers.get("referrer-policy") == "same-origin"assert response.headers.get("x-content-type-options") == "nosniff"