I have an app that is running on (http://simple-pen.surge.sh). This is built with React/Redux for Front-end and Rails for back-end. When I get on the site, I can either sign-up or sign-in and issue a JWT token for the user. Once logged in, I have a set of notebooks I can view. However, it's only when clicking on a notebook, I get redirected to a 404 Page Not Found error.
I'm not sure why I get an error when making the GET request to certain pages. Trying to access "http://simple-pen.surge.sh/notebooks/1/notes" url, but fails. In one scenario, I have it set so if the user is logged in, the "simple-pen.surge.sh" root path redirects the user to their notebooks route i.e. "http://simple-pen.surge.sh/notebooks" which renders the page, but when I make an actual request for this URL directly, I then get the error.
Below are links to GitHub repos for React and Rails app respectively. https://github.com/jamesvphan/simplepen-react https://github.com/jamesvphan/simplepen
Any help or knowledge as to why this is occurring would be great!
Creating a 404 Page In React, you do this by creating a not found component that will render on routes that don't exist. This article assumes you already have a working React application with routing set up. If you don't, create a React application and then install React Router. Create a new file called NotFound.
You can't access your routes directly. you have to do this little hack for that.
npm run build
command you have to go to the build folder of your react application folder.read more about this issue: here
Follow below step to resolve(only 4 surge):
npm run build
cd build
cp index.html 200.html
surge
From here you can continue as usual
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With