无法访问React URL [英] React URLs are not Accessible

查看:254
本文介绍了无法访问React URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆