I use reactJS for a multiple routes app.
Historically, I hosted my app on Netlify, then I implement a prerendering with react-spa-prerender in order to improve SEO.
Recently I migrate it towards GitHub pages, keeping this prerendering effective.
Then, I try to get rid of this prerendering and my subpages were not served anymore.
My App.js returns this :
return (
<>
<div className="App" id="capture">
<AppContext.Provider value={appContext} >
<div className={`${theme}`}>
<BrowserRouter>
<Routes>
<Route exact path={pathBuilder('/')} element={<CurriculumVitae domain={EnumDomain.GENERIC} />} />
<Route path={pathBuilder('/dev')} element={<CurriculumVitae domain={EnumDomain.DEV} />} />
<Route path={pathBuilder('/maths')} element={<CurriculumVitae domain={EnumDomain.MATHS} />} />
</Routes>
</BrowserRouter>
</div>
</AppContext.Provider>
</div>
</>
);
The method pathBuilder(path) return this :
const pathBuilder = (path) => {
return `${process.env.NODE_ENV === 'production' ? '/cv' : ""}${path}`;
}
This is due to the fact that the app is served on GitHub Pages at "https://[githubname].github.io/cv", and the base domain page is "https://[githubname].github.io", I have to add the suffix '/cv' and then add the good suffix corresponding to the page ('/', '/dev', '/maths').
Here are my dependencies in package.json :
"react-dom": "^18.2.0",
"react-router-dom": "^6.16.0",
"react-scripts": "5.0.1",
"react-spa-prerender": "^1.0.14",
Can somebody help me with this problem ?
Thank you in advance.