I need to perform a simple redirect of URL in the following app. When the URL is https:localhost:8080/new; the app needs to redirect to https:localhost:8080/, with the URL being shown in the browser as https:localhost:8080/new. Currently, I get a 'Cannot GET /new' error message. The ReactJS code is:
import React from 'react';
import { BrowserRouter, Router, Route, Switch, Link, NavLink, Redirect } from 'react-router-dom';
import createHistory from 'history/createBrowserHistory';
import TabComponent from '../components/TabComponent';
export const history = createHistory();
const testText1 = () => (<div><p>asdas1</p></div>);
const testText2 = () => (<div><p>asdas2</p></div>);
const testText3 = () => (<div><p>asdas3</p></div>);
const AppRouter = () => {
console.log('HEREEE');
return (
<BrowserRouter history={history}>
<div>
<Switch>
<Route path="/" component={testText1} exact={true} />
<Route path="/new" component={testText2} />
<Redirect from="/new" to="/" push />
<Route path="/latest" component={testText3} />
</Switch>
</div>
</BrowserRouter>
);
}
export default AppRouter;