我有一个静态文件服务器(用 vibe.d 制作)为使用 ES6 模块但扩展名为 .mjs 的网站提供服务。
我的浏览器(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 类型吗?
这是我的 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);