You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
Hi @lberthaut, thanks for including links. I see what you mean.
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)
Activity
up4k73 commentedon Aug 2, 2022
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...
gitname commentedon Aug 3, 2022
Hi @lberthaut, thanks for including links. I see what you mean.
The
react-gh-pagestutorial doesn't address routing. However, I do have some experience with it, including on GitHub Pages.I think you have two options:
<HashRouter>instead of<BrowserRouter>. -- OR --<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 yourindex.htmlfile, creating a404.htmlfile containing specific code, and passing abasenameprop to the<BrowserRouter>element)Hi @up4k73, thanks for sharing your hypothesis.
Update README with BrowserRouter instructions
MSSRPRAD commentedon Jun 4, 2023
@gitname I am facing the same issue. When I use HashRouter it doesn't redirect at all. https://github.com/mssrprad/Blog