52045

React URLs are not Accessible

Question:

hi i've run following command pm2 start process.json on ec2 AWS.

Here is my process.json file

{ "script": "serve", "env": { "PM2_SERVE_PATH": './build', "PM2_SERVE_PORT": 5000 } }

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.

Below is my file structure

<a href="https://i.stack.imgur.com/MODku.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/MODku.png" data-original="https://i.stack.imgur.com/MODku.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

I am generating the project using npm run build then pm2 start process.json

Answer1:

So the app starts up and you can access the root page? What about your routes? Are they set up properly? Are you using react-routing or something else?

This sounds like a routing issue. Does it only happen on the AWS platform?

Answer2:

Hi I found a solution to this problem.

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.

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 <strong>CTRL + D</strong>

Recommend

  • Installing SSL cert on Amazon EC2 ELB
  • Can I put a + sign in a folder with IIS?
  • Open hyperlink on click on an ggplot/plotly chart
  • Symfony2 redirect to https route fails (uses wrong port)
  • How to rotate the dial in a gauge chart? Using python plotly
  • How to draw a line dynamically in android [duplicate]
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • php script is parsing content from RTE (tt_news) but internal links are not appearing as speaking ur
  • How can I get the choice “H2” back in the H2 consol?
  • Upload file that is in the cpan database
  • In matplotlib, how do you change the fontsize of a single figure?
  • Spring: No transaction manager has been configured
  • Approximate Order-Preserving Huffman Code
  • accepts_nested_attributes_for practical form use for in Rails 3
  • Jquery popup on mouse over of calendar control
  • Object and struct member access and address offset calculation
  • WPF Visiblity Binding to Boolean Expression with multiple Variables
  • how to upload multiple files in c# windows application
  • MS Access - How to change the linked table path by amend the table
  • JBoss External Properties Files in Classpath
  • Connect .sks to skscene.h
  • Sort List of Strings By Version
  • Why does access(2) check for real and not effective UID?
  • Checking free space on FTP server
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Circular dependency while pushing http interceptor
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • AngularJs get employee from factory
  • Benchmarking RAM performance - UWP and C#
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • How to set the response of a form post action to a iframe source?
  • How do I configure my settings file to work with unit tests?
  • Change div Background jquery
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Binding checkboxes to object values in AngularJs