我已经在
Vultr
服务器中部署了我的 React 应用程序并在服务器中安装了 nginx
并通过运行以下命令配置了以下设置。
$ sudo nano /etc/nginx/sites-available/default
server {
listen 80;
server_name somedomain-test.com www.somedomain-test.com;
root /var/www/somedomain-test.com/build;
index index.html;
}
我确实运行了
npm run build
并将构建文件夹复制到以下目标文件夹/var/www/automateandmore.com/build
然后运行以下命令:
$ sudo nginx -t
$ sudo systemctl restart nginx
我能看到前端。现在我已经从文件夹位置
server.js
启动了 src/
但我仍然可以看到它正在调用 localhost:8000/service/listofblogs:
我该如何解决这个问题,有人可以建议吗?
这是我的 package.json 设置
{
"name": "myblogs",
"version": "0.1.0",
"private": true,
"dependencies": {
.....
},
"proxy": "http://localhost:8000",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
....
}
}
.env 文件
DANGEROUSLY_DISABLE_HOST_CHECK=true
REACT_APP_URL=http://somedomain-test.com