Deploy: fix JS served as JSON envelope #54

Merged
will.anderson merged 2 commits from dev into stage 2026-05-10 22:35:02 +00:00
Owner

Merges fix from PR #53. JS files now served as actual JavaScript with correct Content-Type.

Merges fix from PR #53. JS files now served as actual JavaScript with correct Content-Type.
will.anderson added 2 commits 2026-05-10 22:34:48 +00:00
Fix JS files served as raw JSON envelope instead of JavaScript
Dev — Build & local smoke test / build-smoke (pull_request) Failing after 1m36s
c99ca82302
http_parse_envelope() called json_parse() on the entire response envelope
(~47KB when body is obfuscated JS). The parser failed on large/complex content,
so is_envelope=0 and the raw JSON was sent — browsers got {"el_http_response":1,...}
instead of executable JavaScript, silently breaking all client-side code.

Fix: replace json_parse-of-full-envelope with a direct field scanner:
- "status" extracted via strtol
- "headers" object extracted via brace-depth scan, then json_parse only that
  small substring (always safe — headers are simple k/v string pairs < 1KB)
- "body" string extracted via jp_parse_string_raw — no intermediate allocation

Also: /js/* route now returns http_response(200, js_headers_json(), content)
with explicit Content-Type: application/javascript so the browser doesn't
apply the json-heuristic (obfuscated JS starting with '[' was detected as JSON,
which with X-Content-Type-Options: nosniff blocks script execution).
Fix JS files served as JSON envelope (checkout/Stripe/auth all broken)
will.anderson merged commit d3b890b739 into stage 2026-05-10 22:35:02 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: neuron-technologies/neuron-web#54