fix: remove upgrade-insecure-requests from CSP — blank homepage on HTTP deployments (#525)
* Initial plan * fix: remove upgrade-insecure-requests from CSP to fix blank homepage over HTTP The upgrade-insecure-requests CSP directive instructs browsers to upgrade same-host HTTP requests to HTTPS (preserving port). In the default plain-HTTP Docker deployment (port 4174), the browser upgrades every asset URL to https://host:4174/... and sends a TLS Client Hello to the HTTP nginx port. nginx cannot parse TLS bytes as HTTP and returns 400 with no method/URI (the observed "400 - -" log pattern). All JS/CSS bundles fail to load, React never mounts, page stays blank. Fix: remove "; upgrade-insecure-requests" from the CSP string. This directive is intended for HTTPS-only sites and is harmful on plain-HTTP servers. Removing it does not weaken security for HTTP deployments. Agent-Logs-Url: https://github.com/DanielVolz/medassist-ng/sessions/9c4db7bd-1272-49ca-abf3-73c2ad5a5354 Co-authored-by: DanielVolz <3275994+DanielVolz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DanielVolz <3275994+DanielVolz@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,14 @@ Purpose: persistent agent work memory to survive context loss.
|
||||
|
||||
## Entries
|
||||
|
||||
### 2026-04-10
|
||||
|
||||
- Task: Investigate and fix the production blank-homepage bug (user report: both containers running, blank page, many `400 - -` log lines in frontend container).
|
||||
- Root cause: `upgrade-insecure-requests` directive was present in the `Content-Security-Policy` header in `frontend/nginx.conf`. This directive instructs browsers to upgrade all same-host HTTP requests to HTTPS (preserving the port). When users access the app over plain HTTP (e.g., `http://host:4174/`), the browser receives this CSP and upgrades subsequent asset requests (`/assets/index-*.js`, `/assets/index-*.css`, favicons, API calls) to `https://host:4174/...`. The nginx container only speaks plain HTTP on port 4174, so it receives TLS Client Hello bytes which it cannot parse as an HTTP request. nginx returns `400 Bad Request` with no parseable method or URI — producing the `400 - -` log pattern. All JS/CSS bundles fail to load, React never mounts, and the page stays blank.
|
||||
- Fix: Removed `; upgrade-insecure-requests` from the CSP string in `frontend/nginx.conf` (line 20). No other changes needed.
|
||||
- Validation notes: The directive is safe to remove — `upgrade-insecure-requests` is designed for HTTPS-only sites and is harmful when the server runs on plain HTTP. Removing it does not weaken security for self-hosted HTTP deployments (mixed content is not a concern when the origin itself is HTTP). If a reverse proxy with TLS termination is added in front, the directive can be re-introduced at the proxy level.
|
||||
- Files touched: `frontend/nginx.conf`.
|
||||
|
||||
### 2026-03-25
|
||||
|
||||
- Task: Diagnose PR #475 GitHub CI failure for the frontend build job and fix testing/build-scope issues only.
|
||||
|
||||
Reference in New Issue
Block a user