0

I have to add routes for front end as "/How-it-works" and for admin end as "Admin/Route-name", with following code it works fine and i can access with refresh as well locally but when i create build and access on server it generate an error.

    <Router history={history} >
        <Switch>
            <FrontEndLayoutWrapper exact path="/" component={Home} />
            <FrontEndLayoutWrapper exact path="/How-it-works" component={HowItWorks} />
            <AdminAuthRoute    exact  path="/Admin" component={AdminIndex} />
            <PrivateRouteAdmin exact path="/Admin/Companies" component={CompanyList} />
            <PrivateRouteAdmin exact path="/Admin/Festivals" component={FestivalList} />
            <PrivateRouteAdmin exact path="/Admin/Dashboard" component={Dashboard} />              
        </Switch>
    </Router>

In webpack.config.js i have output property in module.exports as this:

    output: {
      path: path.join(__dirname, 'bundle'),
      filename: 'index_bundle.js',
      publicPath: '/',
   }

and i have already set historyApiFallback to true in module.exports as well.

devServer: {
  historyApiFallback: true
}

Error:

GET http://localhost:8080/Admin/index_bundle.js net::ERR_ABORTED 404 (Not Found)

enter image description here

hu7sy
  • 855
  • 1
  • 10
  • 29
  • Possible duplicate of [React routing, path not working, bundle not found](https://stackoverflow.com/questions/50275901/react-routing-path-not-working-bundle-not-found) – JJJ Nov 06 '18 at 11:03
  • This is something to do on serverside routing. on apache or nginx or at least express that boots up react app. – emil Nov 06 '18 at 11:21
  • You might have to set contentBase in the webpack devServer configuration https://webpack.js.org/configuration/dev-server/#devserver-contentbase – hbentlov Nov 06 '18 at 11:47

0 Answers0