javascript - 在 Azure 上提供 React App 时出现 ENOENT 错误
问题描述
我在 Azure 上托管了一个 React 网站,并且成功地提供了页面而没有问题。
但是,我经常在 Web App 日志中收到错误消息,例如:
2021-03-01T15:01:33.957751902Z 15:01:33 0|static-page-server-8080 | [2021-03-01T15:01:33.956Z]
Error while serving /home/site/wwwroot/build/profile with content-type text/plain :
ENOENT: no such file or directory, open '/home/site/wwwroot/build/profile'
例如,当我导航到: https ://www.webaddress.com/account/profile 时会发生此错误
需要明确的是,仍然可以毫无问题地提供页面。那么为什么我会收到此错误?我该如何阻止它?
解决方案
首先,验证分发文件夹并检查文件 index.html,标签必须是这样的
<base href="/">
而你的“outputPath”必须是这样的“dist”,
"outputPath": "dist",
此致
推荐阅读
- c# - IIS 没有收到对 HTML 的更新?
- python - Pandas 将每年与某个属性关联的列合并为单独的列
- javascript - 有没有办法使用 Web Audio API 重新采样音频流?
- python - 在 Plotly 中使用三个 1D 浮点数组创建 3D 曲面图
- javascript - 是什么导致 React.js 上的表单解析错误
- reactjs - 创建反应应用程序 - 小型 EC2 服务器上的 `yarn build` 占用 100% CPU 并使其无响应
- c++ - 树形图的直径
- python - 从经度和纬度获取国家名称
- amazon-web-services - 将事件数据从 Amazon EventBridge 传递到 AWS Fargate 任务
- swift - 如何创建用户可以在其上添加精确点的 3d 地球?