【发布时间】:2019-08-15 17:10:09
【问题描述】:
我目前的设置
- 我有一个使用基本 html+css 制作的网站。 (比如https://example.com)
- 我在https://example.com/register 托管了一个 React 应用程序
为此,我已经在我的 package.json 中设置了
"homepage": "https://example.com/register/"
在我的 App.js 上
<Router history={history} basename="/register">
</Router>
我的 NGINX 看起来像这样:
server {
listen 5400;
access_log /var/log/nginx/wordpress-access.log;
error_log /var/log/nginx/wordpress-error.log;
location / {
root /home/ubuntu/...../build/;
index index.html;
expires 1d;
try_files $uri /index.html;
}
}
server {
listen 443 ssl;
listen [::]:443;
index index.php index.html index.htm;
server_name example.com;
location / {
... old setup
}
location /register {
proxy_pass http://127.0.1.1:5400/;
}
}
这就是我想要做的。我想在 url example.com/pricing 上托管相同的 React 应用程序。
我怎样才能做到这一点?我希望代码/逻辑等的重复最少。
【问题讨论】:
标签: reactjs react-router