Back to TIL
shell

Fixing NGINX wrong MIME type for mjs files

Apparently I deployed mjs JavaScript files for the first time ever. When I checked if everything was loading correctly, every browser greated me with application/octet-stream is not a valid JavaScript MIME type.

Sure enough, when inspecting the responses in the Dev Tools, the Content-Type wasn’t being set properly.

Nginx does set it based on file extensions. The mapping itself lives, on Ubuntu 24, in /etc/nginx/mime.types.

By simply adding mjs, the entire problem was fixed:

-    application/javascript                           js;
+    application/javascript                           js mjs;

A systemctl reload nginx was also necessary.