title: How to perform a simple Redirect in a ReactJS app
body: <p>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:</p>
  
  <pre><code>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 = () =&gt; (&lt;div&gt;&lt;p&gt;asdas1&lt;/p&gt;&lt;/div&gt;);
  const testText2 = () =&gt; (&lt;div&gt;&lt;p&gt;asdas2&lt;/p&gt;&lt;/div&gt;);
  const testText3 = () =&gt; (&lt;div&gt;&lt;p&gt;asdas3&lt;/p&gt;&lt;/div&gt;);
  
  const AppRouter = () =&gt; {
    console.log('HEREEE');
  
    return (
      &lt;BrowserRouter history={history}&gt;
        &lt;div&gt;
          &lt;Switch&gt;
            &lt;Route path="/" component={testText1} exact={true} /&gt;
            &lt;Route path="/new" component={testText2} /&gt;
            &lt;Redirect from="/new" to="/" push /&gt;
            &lt;Route path="/latest" component={testText3} /&gt;
          &lt;/Switch&gt;
        &lt;/div&gt;
      &lt;/BrowserRouter&gt;
    );
  }
  
  export default AppRouter;
  </code></pre>