如何在 IIS 上托管 create-react-app-2 build

How to host create-react-app-2 build on IIS

我正在尝试在 IIS 上托管一个 React.js 应用程序,该应用程序是使用 create-react-app (react-scripts v2.1.5) 创建的。

我不断收到以下类型错误:


我已经尝试了这个问题中提到的所有方法,但无济于事:

按照 CRA 构建脚本的建议使用“serve -s build”托管它工作正常,但我想通过 IIS 托管它。

有什么明显的我遗漏的吗? 任何帮助将不胜感激。

事实证明,解决方案是添加 "homepage": "."到我项目的 package.json 文件。

这里有一些链接以获取更多信息:

https://facebook.github.io/create-react-app/docs/deployment#building-for-relative-paths

https://github.com/facebook/create-react-app/issues/1487

https://github.com/facebook/create-react-app/issues/1480

https://github.com/facebook/create-react-app/issues/1094

https://github.com/facebook/create-react-app/pull/1489