Firebase托管中Angular 8的Mime错误

时间:2019-07-05 15:54:17

标签: angular firebase electron firebase-hosting

我有一个Angular 8应用程序,该应用程序托管在Firebase上,并通过以下方式在客户端运行:Go-Astilectron(Astilectron 0.30和Electron 4.0.1)。

问题是我在某些客户端中遇到了以下错误(它正好在加载Angular代码时发生,因此Astilectron仅显示空白页):

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.
main-es2015.5a90aaf45a8347384655.js:1 

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.

在某些情况下,我们设法通过重新加载页面来解决此问题,但是在其他情况下,无论我做什么,该页面都不会加载。

我进行了一些研究,发现这可能与注册服务工作者的应用有关,但这不是我的情况。

此外,由于我使用Firebase Hosting服务静态站点,因此我没有进行任何MIME配置。

有人可以帮助我吗?

4 个答案:

答案 0 :(得分:0)

请确保index.html中的head包括:

<base href="/">

请参阅:https://github.com/angular/angular-cli/issues/10325#issuecomment-399329033

在未正确设置注册表mime类型的Windows计算机上运行Python服务器时,也会发生此错误。

请参阅:https://github.com/pallets/flask/issues/1045#issuecomment-42202749

答案 1 :(得分:0)

我通过简单地运行class MyFooClass: UIViewController { var foo: Foo? init(with foo: Foo) { self.foo = foo super.init(nibName: nil, bundle: nil) } public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.foo = nil } } 然后刷新浏览器来解决此问题。

希望这会有所帮助!

答案 2 :(得分:0)

对我来说,浏览器的空缓存和硬重载已解决了该问题。

答案 3 :(得分:0)

我遇到了这个问题。

转到angular.js并检查“ outputPath”的值。如果将其设置为“ dist / your-project-name”之类的内容,请尝试将其更改为“ dist /”,然后重新部署,然后进行站点的硬刷新(Ctrl + F5)。