React:使用PM2部署时找不到404

时间:2019-10-03 04:43:16

标签: reactjs

我尝试通过以下流程部署我的React网站:

  1. 反应脚本构建
  2. pm2启动pm2.json

pm2.json:

{
  "apps": [
    {
      "script": "serve",
      "name": "my-app",
      "log_date_format" : "DD-MM HH:mm:ss Z",
      "out_file": "out.log",
      "error_file": "error.log",
      "env": {
        "PM2_SERVE_PATH": "./build",
        "PM2_SERVE_PORT": 8089
      }
    }
  ]
}

该应用将在http://localhost:8089/上运行,并且每个链接都可以正常运行。 但是,当我单击刷新或在某个页面中单击F5时,例如:http://localhost:8089/device/list-api,它将得到:

Failed to load resource: the server responded with a status of 404 ()

我错过了pm2或package.json的任何配置吗?

使用react-scripts start时不会发生此问题。

感谢阅读。

0 个答案:

没有答案