我在 kubernetes 上部署了我的角度应用程序(静态网页),并尝试从 Google Chrome 启动它。我看到应用程序正在加载,但浏览器上没有显示任何内容。检查浏览器控制台后,我可以看到此错误
“无法加载模块脚本:需要 JavaScript 模块脚本,但服务器以 MIME 类型“text/html”进行响应。根据 HTML 规范,对模块脚本强制执行严格的 MIME 类型检查。” 对于(main.js,poylfill.js,runtime.js)文件。我研究了几个论坛,一个可能的根本原因可能是因为标签type中的属性<script>应该是 type=text/javascript 而不是在type=module执行 ng build 后在 dist 文件夹下生成的 index.html 文件中。我不知道如何对构建过程中生成的这些标签进行更改,并且我的 ng-build 命令由 docker 命令处理。
我尝试访问的 URL 类似于:“http://xxxx:portnum/issuertcoetools
注意:该主机xxxx:portnum也将被许多其他应用程序使用。
对于此问题有任何解决方法或解决方案吗?
index.html - 在本地运行 ng-build 后生成(这与我在 kubernetes POD 中看到的也相同)
<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<title>Data Generator</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<style type="text/css">@font-face{font-family:'Roboto';font-style:normal;font-weight:300;font-display:swap;src:url(https://fonts.gstatic.com/s/roboto/v29/KFOlCnqEu92Fr1MmSU5fCRc4AMP6lbBP.woff2) format('woff2');unicode-range:U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;}@font-face{font-family:'Roboto';font-style:normal;font-weight:300;font-display:swap;src:url(https://fonts.gstatic.com/s/roboto/v29/KFOlCnqEu92Fr1MmSU5fABc4AMP6lbBP.woff2) format('woff2');unicode-range:U+0400-045F, U+0490-0491, …Run Code Online (Sandbox Code Playgroud)