问题描述
我在ec2 AWS上运行了pm2 start process.json
命令.
hi i've run following command pm2 start process.json
on ec2 AWS.
这是我的process.json
文件
{
"script": "serve",
"env": {
"PM2_SERVE_PATH": './build',
"PM2_SERVE_PORT": 5000
}
}
当我运行上面显示的pm2命令时.我可以访问基本URL.但是,当我从浏览器中输入Sub URL时,它显示的页面包含404 |找不到所需的路径.
When I run the pm2 command shown above. I can access the Base URL. But when I type the Sub URLs from browser, it shows a page that contains 404 |The requested path cannot be found.
下面是我的文件结构
我正在使用npm run build
然后是pm2 start process.json
推荐答案
我找到了解决此问题的方法.
Hi I found a solution to this problem.
当我在pm2
上使用服务时,只要找不到url资源,它就会显示404页面.要解决我在ec2上使用screen
的问题.
When I use serve on pm2
it shows 404 page whenever it didn't find a url resource. To resolve that I used screen
on ec2.
要打开新屏幕,请输入screen
然后在您的react文件夹中键入命令serve -s build -p 5000
现在,您可以使用 CTRL + D
To open a new screen type screen
Then in your react folder type command serve -s build -p 5000
Now you can detach your screen using CTRL + D
这篇关于无法访问React URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!