gitname / react-gh-pages

Deploying a React App (created using create-react-app) to GitHub Pages
6.6k stars 922 forks source link

GitHub Pages shows 404 error when navigating #139

Closed raviprakash11 closed 1 year ago

raviprakash11 commented 1 year ago

Hi @gitname,

I face this issue recently, "unable to navigate from one ui-component to another ui-component on gh pages". My testapp is successfully navigating me from one ui component to another ui component in my local, but when i deployed my app in gh page, i don't know where it is breaking, first screen is loading successfully but when its come to anyother screen it is throwing 404 error .

testapp url - https://raviprakash11.github.io/elocution/

Please help me on this ! Thanks in Advance.

gitname commented 1 year ago

Hi @raviprakash11, since routing is working when served by your local machine, but not when deployed to GitHub Pages, I think you are encountering the limitation of GitHub Pages described here; i.e.

GitHub Pages doesn’t support routers that use the HTML5 pushState history API under the hood (for example, React Router using browserHistory).

I recommend applying one of the two workarounds described in the following comment (which is based upon the article linked in the previous paragraph): https://github.com/gitname/react-gh-pages/issues/104#issuecomment-1203373499

Please let us know (i.e. me and future readers) what you end up trying and whether it fixes the issue.

raviprakash11 commented 1 year ago

Hi @gitname ,

I appreciate for quick response. Sure, I'll check and get back to you.

Thanks.

raviprakash11 commented 1 year ago

Hi @gitname ,

I modified my router file as per your last comment. https://github.com/gitname/react-gh-pages/issues/104#issuecomment-1203373499

Now, it is working fine. Hence, closing this issue.

Thanks.

gitname commented 1 year ago

Glad it's working! Thank for following up and closing the issue.