I have a static file server (made with vibe.d) serving a website that uses ES6 modules but with .mjs extension.
My browser (Chromium on Arch Linux) is throwing an error when it fetches the module files server responded with a non-JavaScript MIME type of "application/octet-stream"
.
It looks like I need to set the MIME type files with the .mjs from "application/octet-stream" to "application/javascript". How do I do this?
I could change all the scripts to .js
but that is but I would rather figure out how to fix it right.
How would I change the MIME type for a file being fetched? Or probably better, can I change the default MIME type for all .mjs files?
Here is my d code with vibe.d:
auto router = new URLRouter;
auto fileServerSettings = new HTTPFileServerSettings;
fileServerSettings.encodingFileExtension = ["gzip" : ".gz"];
router.get("/gzip/*", serveStaticFiles("./public/", fileServerSettings));
router.get("/ws", handleWebSockets(&handleWebSocketConnection));
router.get("*", serveStaticFiles("./public/",));
listenHTTP(settings, router);