【发布时间】:2019-03-05 06:03:29
【问题描述】:
我正在尝试使用 Docker 和 Nginx 来部署我的 Angular 应用程序,但是,我遇到了一个问题。
当我运行命令:npm run build 时,我的 index.html 有以下脚本引用:
<body>
<script type="text/javascript" src="runtime.js"></script>
<script type="text/javascript" src="polyfills.js"></script>
<script type="text/javascript" src="styles.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
根据我的感觉,这些是相对路径,因此当 nginx 启动时,我的 index.html 在 firstApp 中,然后在访问这些文件时,资源 URL 应创建为:
http://localhost/firstApp/runtime.js
但是当我在浏览器中运行应用程序时,我收到 404 错误,因为 Nginx 正在尝试在以下位置查找资源:
http://localhost/runtime.js
有没有办法解决这个问题?
【问题讨论】: