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');
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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');