Answer the question
In order to leave comments, you need to log in
Routing not working on hosting?
I am using create react app. Routing works locally. When uploaded to hosting - no. More precisely, if you simply enter mysite.by, and then switch to the menu, then everything works, that is, if you click "contacts" in the menu, it will go to mysite.by/contacts , and if you immediately enter mysite.by/ into the address bar contacts, it gives an error
class App extends React.Component {
render() {
return (
<BrowserRouter>
<div className="app-wrapper-content">
<Header />
<Route path="/products" render={() => <ProductsContainer />} />
<Route exact path="/" render={() => <MainPage />} />
<Route exact path="/about" render={() => <About />} />
<Route exact path="/jay_advices" render={() => <Advices />} />
<Route exact path="/contacts" render={() => <ContactForm />} />
</div>
<Footer />
</BrowserRouter>
);
}
}
Answer the question
In order to leave comments, you need to log in
It looks like you have a static server on your hosting, or only the root route is processed. You need to give index.html for all non-static paths, then everything will work.
Serving Apps with Client Side Routing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question