Skip to content

Commit ebdb646

Browse files
authored
Node.js serving with absolute path
It’s safer to use the absolute path of the directory that you want to serve, in case you run the express app from another directory.
1 parent 3124328 commit ebdb646

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react-scripts/template/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ const express = require('express');
12421242
const path = require('path');
12431243
const app = express();
12441244

1245-
app.use(express.static('./build'));
1245+
app.use(express.static(path.join(__dirname, 'build')))
12461246

12471247
app.get('/', function (req, res) {
12481248
res.sendFile(path.join(__dirname, './build', 'index.html'));

0 commit comments

Comments
 (0)