Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React website throw a 404 page not found error on reloading the page. #55

Open
Debojyotibabai opened this issue Feb 12, 2021 · 3 comments

Comments

@Debojyotibabai
Copy link

Debojyotibabai commented Feb 12, 2021

Whenever I reaload my react website, it throws me page not found error. What I suppose to do? But there is no issue with my other react projects that has been deployed in github.

To push new/updated code to my gthub repo, I write this code ->

  1. git add .
  2. git commit -m "change css"
  3. git push origin master
  4. npm run deploy

What is the problem?

Capture

@T-Damer
Copy link

T-Damer commented Jul 30, 2021

Look at your URL, it must be github.io/{yourproject}. Edit your packaje.json and add homepage (check the readme of this repository)

@israelmrios
Copy link

It looks like you are using a GitHub User Site. I had the same issue, and found it was the way I was Handling my Routing. I was using <BrowserRouter> on my root index.js file but GitHub Pages does not support browser history like your browser does. I switched my routing to <HashRouter> this type of router uses the hash portion of the URL to keep the UI in sync with the URL.

ReactDOM.render( <React.StrictMode> <HashRouter> <App /> </HashRouter> </React.StrictMode>, document.getElementById('root') );

@b-smiley
Copy link

Look at my PR it helped me fix this issue:

#161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants