[英]Node with React: How change port number to url
I have a Nodejs server and within that server there is a React app.我有一个 Nodejs 服务器,在该服务器中有一个 React 应用程序。 Currently I am running the server on localhost:8000
and the React app is on localhost:3000
.目前我在localhost:8000
上运行服务器,而 React 应用程序在localhost:3000
上。 What I wanted to do is have the server be accessible through the address localhost/server
and the app to be accessible through the address localhost/admin/
So for example to open my app I would have to type https://localhost/admin
and to access the server endpoints, the app would have to send requests to https://localhost/server
.我想做的是让服务器可以通过地址localhost/server
访问,应用程序可以通过地址localhost/admin/
访问 例如,要打开我的应用程序,我必须输入https://localhost/admin
和要访问服务器端点,应用程序必须将请求发送到https://localhost/server
。 Hope I'm being clear enough.希望我说得够清楚了。
You need to change your apache server settings您需要更改您的 apache 服务器设置
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.