不允许的 MIME 类型(“text/html”)错误 - Angular Github 页面

kon*_*ban 1 github github-pages angular

我刚刚将一个 Angular 8 项目部署到我的 Github 存储库,但 Github 页面上没有显示任何内容,但我在浏览器控制台上看到一个错误。

在 Firefox 上,错误说:

Loading module from “https://theotherspace.illiteratibooksandcoffee.com/theotherspace/runtime-es2015.27965c48d77c449cb93c.js” was blocked because of a disallowed MIME type (“text/html”).

在 Chrome 上:

Failed to load resource: the server responded with a status of 404 ()

以下是截图:

火狐错误 铬错误

Pra*_* M. 7

我在使用来自不同存储库(而不是父 github.io 存储库)的 Github 页面时遇到了类似的问题。

通过更改base href为当前目录解决了这个问题。

早些时候

<base href="/">
Run Code Online (Sandbox Code Playgroud)

改成

<base href="./">
Run Code Online (Sandbox Code Playgroud)

我参考了https://github.com/angular/angular/issues/30835直到我找到了这个解决方案。