问题描述
我希望在设置 Hapijs 以托管带有路由的 angular 项目方面得到一些帮助。
我的 Angular 静态文件位于名为 public 的目录中。
我的 hapijs 文件设置如下:
const Hapi = require('@hapi/hapi');
const Inert = require('@hapi/inert');
const Path = require('path');
const server = new Hapi.Server({
port: 4200,host: 'localhost',routes: {
files: {
relativeto: Path.join(__dirname,'public'),}
}
});
const provision = async () => {
await server.register(Inert);
server.route({
method: 'GET',path: '/{param*}',handler: {
file: 'index.html'
}
});
await server.start();
console.log('Server running at:',server.info.uri);
};
provision();
我遇到的问题是,每当我浏览到 Web 服务器时,它都会设法加载 index.html,但无法加载所需的角度模型(runtime.js、polyfills.js、main-es2015.js)以下错误:
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)