html - bundle.js 未在静态 html 文件中成功加载,但请参阅
问题描述
我在使用StaticFiles的asp.net核心Web项目的wwwroot中有一个静态index.html:
<html>
...
<body>
...
<script src="~/scripts/bundle.js"></script>
</body>
</html>
Web 应用程序发布后。bundle.js 无法成功加载,在 Chrome 中按 F12 后发现浏览器试图通过 url 加载 js: https ://127.0.0.1:5001/~/scripts/bundle.js
请提供线索。谢谢!顺便说一句,Web 应用程序在本地运行流畅,没有此类错误。
解决方案
这实际上是一个 Nginx 配置问题。https://www.***.com/subpath1/test.html.
nginx 将 subpath1 代理到托管 test.html 的本地端口 5588。在 test.html<script src="bundle.js">
中没有
https://www.***.com/subpath1/bundle.js
按预期引用,但https://www.***.com/bundle.js
因此更新 test.html src 属性src="subpath1/bundle.js"
解决了问题。谢谢大家~
推荐阅读
- pyinstaller - pyinstaller -- 没有名为 pyWinhook 的模块
- css - 使用 ngClass 添加样式时出现样式错误
- string - 大会 8086 如何将 db 转换为十进制数?
- cypress - 单击任何按钮/锚标记正在注销我
- scala - 等待 N 秒让演员在 Scala 中返回
- javascript - 如何将弯曲边缘添加到 d3 路径线?
- node.js - 如何通过 node exec 命令在 Windows 上添加环境变量
- java - Java Spark ML - Spark ML 3.1+ 问题的预测/预测
- c# - 根据模式拆分流的最快方法
- google-sheets - 谷歌表中的数据验证有 2 列