【问题标题】:React app fails to run with Apache reverse proxyReact 应用程序无法使用 Apache 反向代理运行
【发布时间】:2021-04-26 07:01:18
【问题描述】:

我正在使用reverse-proxy apache2 模块将来自https://my_server.com/test_app/ 的任何请求转发到在:3000 上运行的react 生产应用程序。

如果我使用https://my_server.com:3000,一切正常。但是https://my_server.com/test_app/ 无法获取静态文件并且反应无法加载。 好像是在 80 端口请求静态文件,但是我的 react 应用是在 3000 上运行的。

我该如何解决这个问题?

package.json

{
  "private": true,
  "homepage": "/",
  ...
}

httpd.conf

ProxyPass /test_app http://localhost:3000

【问题讨论】:

    标签: reactjs linux apache reverse-proxy serve


    【解决方案1】:

    我没有使用serve,而是将构建的内容放入/var/www/html/<Some-Directory> 的目录中(所以我只使用Apache)。我必须为<Router /> 定义basename 并更新我的链接,但现在似乎工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-09
      • 2019-12-21
      • 2017-08-09
      • 1970-01-01
      相关资源
      最近更新 更多