Hapijs Web 服务器 + Angular 路由无法加载 runtime.js

问题描述

我希望在设置 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...