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

page deployed but paths doesn't work #104

Open
lberthaut opened this issue Jun 24, 2022 · 3 comments · May be fixed by #132
Open

page deployed but paths doesn't work #104

lberthaut opened this issue Jun 24, 2022 · 3 comments · May be fixed by #132
Assignees
Labels
react-router App uses React Router

Comments

@lberthaut
Copy link

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/)

@up4k73
Copy link

up4k73 commented 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
Copy link
Owner

gitname commented Aug 3, 2022

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.

@MSSRPRAD
Copy link

MSSRPRAD commented 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

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

Successfully merging a pull request may close this issue.

4 participants