我有一个使用vibe.d创建的静态文件服务器,它提供了一个使用.mjs扩展名的ES6模块的网站。
当我的浏览器(Arch Linux上的Chromium)获取模块文件时,它会抛出一个错误:server responded with a non-JavaScript MIME type of "application/octet-stream"
。
看起来我需要将带有.mjs的文件的MIME类型从“application/octet-stream”更改为“application/javascript”。我该怎么做呢?我可以将所有脚本更改为.js
,但我更想弄清楚如何正确解决这个问题。
我应该如何更改正在获取的文件的MIME类型?或者更好的方法是,我能否更改所有.mjs文件的默认MIME类型?
以下是我的d代码与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);