Skip to content

Commit 4cce1d9

Browse files
committed
Revert "Simplify static file serving in production"
This reverts commit 6a3bbc0.
1 parent 6a3bbc0 commit 4cce1d9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backend/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ app.use(
1616
credentials: true,
1717
}),
1818
);
19-
app.use(express.static(path.join(__dirname, "./build")));
19+
if (process.env.NODE_ENV === "production") {
20+
app.use(express.static(path.join(__dirname, "./build")));
21+
}
2022

2123
app.use(bodyParser.json({ limit: "50mb" })); //limit limits the data which can be uploaded to server.js from frontend
2224
const store = new MongoDBStore({
@@ -43,7 +45,9 @@ app.use(
4345
);
4446

4547
app.get("/", cors(), (req, res) => {
46-
res.sendFile(path.join(__dirname, "./build", "index.html"));
48+
if (process.env.NODE_ENV === "production") {
49+
res.sendFile(path.join(__dirname, "./build", "index.html"));
50+
}
4751
});
4852

4953
app.use("/en", approute); //routing to all functions

0 commit comments

Comments
 (0)