DEV Community

Discussion on: Unable to navigate to pages in react (MERN app) which is deployed on Heroku

Collapse
 
biomathcode profile image
Pratik sharma • Edited
if (process.env.NODE_ENV === 'production') {
  app.use(express.static('client/build'));
}
app.get('*', (request, response) => {
    response.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
Enter fullscreen mode Exit fullscreen mode

did you add this in your server ??

you can look here at the steps to do the same

github.com/accimeesterlin/mern-sta...

Hope it helps

Chill!!!

Collapse
 
deepikasharma5 profile image
Deepika Sharma

Yes when I add that I am getting the error as this.state.dates.map is not a function. (A mapping error)

Collapse
 
deepikasharma5 profile image
Deepika Sharma

If you can , can you check whether my frontend mapping is correct? Because if I add the above code it is showing mapping error. But the code is completely working on local server.

And without the above code the home page and the mapping inside it are working fine. Only the navigation is not working.
(Actually I referred this person's YouTube video and deployed)