How to access deployed BrowserRouter used react project after depolying into tomcat server

192 views Asked by At

I would like to use BrowserRouter for creating multi-page react appplication where I can access different modules with different router names. I can switch between Home and About modules with http://localhost:3000/home and http://localhost:3000/about respectively.

My main intention to create this router-based application is to deploy the build files into server from where we need to access the project.

I can access my project with http://localhost:8080/myapp/index.html after deploying the files into one of my context folders(myapp).

Problem is how to switch between modules which I can do with http://localhost:3000/home. How to access Home and About modules from deployment.(Tomcat). PLease help me on this.

App.js :

import React from "react";
import "./App.scss";
import ReactDOM from "react-dom";
import { BrowserRouter as Router, Switch, Link, Route } from "react-router-dom";
import About from "./About";
import Home from "./Home";

function App(props) {
  return (
    <Router>
      <Switch>
        <Route path="/home" render={() => <Home />} />
        <Route path="/About" render={() => <About />} />
      </Switch>
    </Router>
  );
}

export default App;
0

There are 0 answers