reactjs - 通过 Apache 反向代理访问 React 开发环境
问题描述
我只是想开始使用基本的 create-react-app。我可以通过典型的 localhost:3000 访问开发环境,但我想通过我的公共 apache 服务器访问它。我已经通过反向代理在子目录中进行了设置:
<VirtualHost *:80>
ServerName example.com
ProxyPass /react-app http://127.0.0.1:3000/
ProxyPassReverse /react-app http://127.0.0.1:3000/
</VirtualHost>
这可行,除了 index.html 中的引用被编码为仅从根目录查看。例如 js 包位于:
<script type="text/javascript" src="/static/js/bundle.js">
当它的实际位置真的下/react-app/static/js/bundle.js
。或者,这也可以制成相对 URI。
我的几个问题:
- 如何在非根目录下运行 react-app 开发环境?
- 或者,有没有比这个 Apache 反向代理方法更好的方法来访问开发环境?
解决方案
推荐阅读
- c# - 当方法返回类型 IEnumerable 时,方法返回 List。但 GetType 显示为 List
- html - 输入字段宽度不受边距影响
- android-studio - 安装失败并显示消息 Failed to finalize session : INSTALL_PARSE_FAILED_NO_CERTIFICATES
- php - 如何使用来自 PhpStorm 的 .htaccess 文件?
- javascript - Hoare 快速排序算法无法正常工作
- rust - 不能在循环中多次借用可变错误
- image - 在Linux中使用file命令的输出分析图像导致Linux shell脚本错误?
- scala - 如何确定问题是否可以在 Scala 中使用尾递归解决
- javascript - Ajax 表单数据不与多个对象一起发送
- java - 比较加密的 sha512+salt 密码时出现问题