react-gh-pages icon indicating copy to clipboard operation
react-gh-pages copied to clipboard

page deployed but paths doesn't work

Open lberthaut opened this issue 3 years ago • 3 comments

Hi,

I deployed my page (https://lberthaut.github.io/projetsportsee/), and put component's paths with Routes. The homepage is goodly deployed but I should be able to change pages by adding a uri (12 or 18 by choosing one of the two first names on the homepag). But when I do, a github 404 error is displayed. In localhost, I have not this matter.

React-gh-pages should handle this or is it not supported? did I make a mistake during deployment?

My Repo : https://github.com/lberthaut/projetsportsee (paths is in projet-sportsee/src/app/)

lberthaut avatar Jun 24 '22 13:06 lberthaut

Hi! Im newbee, But i think you need to enable browserrouter in main js file like this. <BrowserRouter> <App /> </BrowserRouter> I think your main app dont know what you use routing, and it works on your local server, but when you upload on ghp this is doesn't work.

This is just assumption...

up4k73 avatar Aug 02 '22 11:08 up4k73

Hi @lberthaut, thanks for including links. I see what you mean.

image

The react-gh-pages tutorial doesn't address routing. However, I do have some experience with it, including on GitHub Pages.

I think you have two options:

  • (A): Use React Router's <HashRouter> instead of <BrowserRouter>. -- OR --
  • (B): Continue using React Router's <BrowserRouter>, and employ the "trick" described in https://github.com/rafgraph/spa-github-pages (the trick involves adding specific code to the <head> section of your index.html file, creating a 404.html file containing specific code, and passing a basename prop to the <BrowserRouter> element)

Hi @up4k73, thanks for sharing your hypothesis.

gitname avatar Aug 03 '22 01:08 gitname

@gitname I am facing the same issue. When I use HashRouter it doesn't redirect at all. https://github.com/mssrprad/Blog

MSSRPRAD avatar Jun 04 '23 11:06 MSSRPRAD