how to serve react js static files with express js 3f

Solutions on MaxInterview for how to serve react js static files with express js 3f by the best coders in the world

showing results for - "how to serve react js static files with express js 3f"
Maite
21 Nov 2018
1//on your react app run
2npm run build
3//The insert the following code on your server
4const path = require("path");
5app.use(express.static(path.join(__dirname,"nameOfYourReactApp","build")))
6
7//Replace nameOfYourReactApp with the name of your app
8
Emily
24 Apr 2017
1//on your react app run 
2npm run build
3
4//Then insert the following code on your server
5
6const path = require("path");
7app.use(express.static(path.join(__dirname,"nameOfYourReactApp","build")))
8//Replace nameOfYourReactApp with the name of your app
Safiya
09 Nov 2019
1const path = require("path");
2app.use(express.static(path.join(__dirname,"nameOfYourReactApp","build")))
3
4//Replace nameOfYourReactApp with the name of your app
5