DEV Community

Discussion on: Utilizing the power of Docker while building MERN Apps using mern-docker

Collapse
 
junahpark profile image
Junah Park • Edited

I get errors with building a docker container from the following:

"""
Connecting Client and Server using Docker Compose

To do this, we need to tell our server about our client !

In our /server/server.js add this :

// will redirect all the non-api routes to react frontend
router.use(function(req, res) {
res.sendFile(path.join(__dirname, '../client','build','index.html'));
});
"""

I resolved this by replacing "router.use" with "app.use" and adding a path variable to server.js: const path = require('path');