Browser Error: Failed to load module script: Expected a JavaScript MIME type

Web server served `.mjs` with `application/octet-stream` instead of `text/javascript`.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.0.0
Identifier: Browser Error Platform: Web
Common Root Causes:
  • Web server served `.mjs` with `application/octet-stream` instead of `text/javascript`.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Map `mjs` explicitly to `text/javascript` in Nginx `types {}` or `location ~* \.mjs$`.
Safe Diagnostic Command:
curl -sI https://example.com/assets/app-runtime.mjs | grep -i content-type
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

Web server served `.mjs` with `application/octet-stream` instead of `text/javascript`. Recommended diagnostic: `curl -sI https://example.com/assets/app-runtime.mjs | grep -i content-type`. Remediation: Map `mjs` explicitly to `text/javascript` in Nginx `types {}` or `location ~* \.mjs$`.

Worked Examples

  • Run `curl -sI https://example.com/assets/app-runtime.mjs | grep -i content-type` to confirm root cause before applying the fix.

Limitations & Assumptions

  • Always test configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.

Source References & Verification

Resource ID: err-browser-mjs-mime-type-blocked · Independently verified: 2026-11-25

Related Resources