Я использую npm запустить сборку Я пробовал несколько решений, перечисленных ниже
В пакете. json добавлено "домашняя страница ":". " или basepath Попробуйте добавить .htaccess
https://www.andreasreiterer.at/fix-browserrouter-on-apache/ При развертывании на сервере JS тогда это работает. Но хотел развернуть на Apache сервере.
Вот мой код приложения Js.
import { Router, Route, Switch } from "react-router-dom";
import { AdminPrivateRoute } from "./components/admin/AdminPrivateRoute";
import { FacilitatorPrivateRoute } from "./components/facilitation/FacilitatorPrivateRoute";
import { AdminLogin } from "./components/admin/AdminLogin";
import AdminCommonPage from "./components/common/AdminCommonPage";
import AdminRoutes from "./components/admin/AdminRoutes";
import { FacilitatorLogin } from "./components/facilitation/FacilitatorLogin";
import FacilitatorRoutes from "./components/facilitation/FacilitatorRoutes";
import CustomerIndex from "./components/customer/CustomerIndex";
import { CustomerLogin } from "./components/customer/CustomerLogin";
import { CustomerPrivateRoute } from "./components/customer/CustomerPrivateRoute";
// import Home from "./components/customer/Home";
import CustomerRoutes from "./components/customer/CustomerRoutes";
import { history } from "./helpers";
import AboutGame from "./components/customer/AboutGame";
class App extends Component {
render() {
return (
<div>
<Router history={history}>
<Switch>
<Route path="/admin/login/admin" component={AdminLogin} />
<Route exact path="/admin/login" component={AdminCommonPage} />
<AdminPrivateRoute path="/admin" component={AdminRoutes} />
<Route
exact
path="/facilitator/login"
component={FacilitatorLogin}
/>
<FacilitatorPrivateRoute
path="/facilitator"
component={FacilitatorRoutes}
/>
<Route exact path="/about-game" component={AboutGame} />
<Route exact path="/login/index" component={CustomerIndex} />
<Route exact path="/login" component={CustomerLogin} />
<CustomerPrivateRoute path="/" component={CustomerRoutes} />
</Switch>
</Router>
</div>
);
}
}
export default App;