I am building a React App with react + react-router, but I have a problem about the redirections.
I have the next folder structure:
...
/public
/index.html (react index)
/tos/
/terms.html
/privacy.html
...
/src
index.js
App.js
...
And the index.js:
class App extends Component {
render() {
return (
<Router>
<Switch>
<Route exact path="/" component={Home}/>
<Route path="/settings" component={Settings}/>
</Switch>
</Router>
)
}
}
ReactDOM.render(<App/>, document.getElementById('root'));
registerServiceWorker();
The problem is when I want redirect to /public/tos/terms.html or /public/tos/privacy.html, sometimes (more frequently in chrome), I can not. The project render again the index, and show a blank page because the route /public/tos/terms.html or /public/tos/privacy.html is not declared in the Route Switch.
On the other hand, I have other "no-react" project in the same base_url, but listen in other port www.my-project.com:4040/other and I have configured it in the next route: www.my-project.com/other. But in this case, I have the same problem, when I redirect from my React-app to this route, react do no redirect and render again the App.js without components inside.
Somebody could tell me any way for redirect to other place in the same project but out of react?