首页 > 解决方案 > 在 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 时会发生此错误

需要明确的是,仍然可以毫无问题地提供页面。那么为什么我会收到此错误?我该如何阻止它?

标签: javascripthtmlreactjsazure

解决方案


首先,验证分发文件夹并检查文件 index.html,标签必须是这样的

 <base href="/">

而你的“outputPath”必须是这样的“dist”,

          "outputPath": "dist",

此致


推荐阅读