fix(netguard): allow operator-configured origins in local mode - #490
Open
tylerpotts wants to merge 1 commit into
Open
fix(netguard): allow operator-configured origins in local mode#490tylerpotts wants to merge 1 commit into
tylerpotts wants to merge 1 commit into
Conversation
Local mode rejects any request whose Origin header is not a loopback origin. Behind a reverse proxy on a public hostname (JupyterHub's jupyter-server-proxy in the data-science-pack), browsers send the proxy's origin on CORS-mode subresource requests - Vite emits the SPA bundle as <script type=module crossorigin> - so every JS/CSS asset request got a 403 and the UI rendered a blank page (#489). Add server.allowed_origins (NEBI_SERVER_ALLOWED_ORIGINS), a comma- separated allowlist honored by both netguard's request check and the CORS response headers, which crossorigin fetches also require.
✅ Deploy Preview for nebi-docs canceled.
|
7 tasks
tylerpotts
added a commit
to nebari-dev/data-science-pack
that referenced
this pull request
Aug 3, 2026
nebi local mode rejects non-loopback Origin headers, which browsers send on the SPA's crossorigin asset requests, blanking the Nebi tile (nebari-dev/nebi#489). Inject NEBI_SERVER_ALLOWED_ORIGINS with the hub's public origin; requires a nebi build with server.allowed_origins (nebari-dev/nebi#490), older builds ignore the variable.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #489
Summary
Local mode rejects any request whose
Originheader is not a loopback origin (netguard, since #459). When nebi is served through a reverse proxy on a public hostname, the JupyterHub data-science-pack being the shipping example, browsers send the proxy's origin on CORS-mode subresource requests: Vite emits the SPA bundle as<script type="module" crossorigin>/<link crossorigin>. Every JS/CSS asset request therefore returned 403 and clicking the Nebi tile rendered a blank page, while the page navigation itself (no Origin header) and curl-based smoke tests passed.This adds
server.allowed_origins(NEBI_SERVER_ALLOWED_ORIGINS), a comma-separated allowlist of additional origins honored in two places, both of which are required for the browser to load the SPA:netguard.Middlewareaccepts listed origins alongside loopback ones (request-side 403 fix)corsMiddlewareechoes listed origins inAccess-Control-Allow-Origin(response side;crossoriginfetches fail in the browser without it even on a 200)Matching is case-insensitive and tolerates surrounding whitespace and trailing slashes. Default is empty, so behavior is unchanged unless the operator opts in. The desktop app path (
app.go) passes no extra origins.Companion change: nebari-dev/data-science-pack will inject
NEBI_SERVER_ALLOWED_ORIGINS=https://<hub-host>into user pods via the spawner (PR to follow on nebari-dev/data-science-pack#202).Test plan
server.allowed_originssetgo test ./internal/...all greencurl -H "Origin: https://hub..." -> 403with the exact 64-byte netguard body observed at the Envoy gateway) confirming the diagnosis this fix targets