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

GitHub Pages shows 404 error when navigating to other routes #63

Closed
Sarika4497 opened this issue Jul 20, 2021 · 8 comments
Closed

GitHub Pages shows 404 error when navigating to other routes #63

Sarika4497 opened this issue Jul 20, 2021 · 8 comments
Assignees
Labels
react-router App uses React Router

Comments

@Sarika4497
Copy link

16267603562742806764158402205587
I created my portfolio website but when I click on home or about me or skills or contact ...every time I found the error like
1626760492882636820505087115265
How I solve this problem

@T-Damer
Copy link

T-Damer commented Jul 30, 2021

Looks like it's problem with build command, it creates index.html for main page only and javascript can not load new page. Problem is in index.html for every page, or in javascript files. I have the same issue, searched many time, nothing works.

In your condition I can see, that route is github.io/#home, but it must be github.io/myreactportfolio/#home, check <Router> component, routes must be <Route to='myreactportfolio/home component={Home} /> for example

@catherineisonline
Copy link

Having the same issue for a while, found any solution yet? :))

@DarkMG73
Copy link

Likewise, I have encountered the same issue. I'll post back if I figure it out.

@DarkMG73
Copy link

Found the problem: capital letters in the repo name. I change the repo name to the same name, but with all lowercase letters (including the Homepage url in the package.json) and re-deployed. No 404 now. I get a white screen, which is a different problem, but the 404 is gone.

@catherineisonline
Copy link

Found the problem: capital letters in the repo name. I change the repo name to the same name, but with all lowercase letters (including the Homepage url in the package.json) and re-deployed. No 404 now. I get a white screen, which is a different problem, but the 404 is gone.

I have everything in lowercase, however it doesn't help

@Teut2711
Copy link

Teut2711 commented Apr 20, 2022 via email

@israelmrios
Copy link

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') );

@gitname
Copy link
Owner

gitname commented Aug 6, 2022

Hi everyone, sorry about the long wait.

In case you are still getting an HTTP 404 error page when you navigate to other URLs within your app, you may be running into a limitation of GitHub Pages, which is described here, in the official CRA deployment guide: https://create-react-app.dev/docs/deployment/#notes-on-client-side-routing

Also described in that guide are two available workarounds, one of which @israelmrios described above. I recently paraphrased the same two workarounds in the following issue comment: #104 (comment)

@gitname gitname added the react-router App uses React Router label Aug 6, 2022
@gitname gitname changed the title 404 there isn't a Github Pages site here GitHub Pages shows 404 error when navigating to other routes Aug 6, 2022
@gitname gitname closed this as completed Jan 20, 2023
@gitname gitname self-assigned this Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
react-router App uses React Router
Projects
None yet
Development

No branches or pull requests

7 participants