Skip to content

Commit 27995f8

Browse files
committed
👔 Use a 404 status code if page not found (fixes #1136)
1 parent 938222e commit 27995f8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ const app = express()
122122
res.end(JSON.stringify({ success: false, message: e }));
123123
}
124124
})
125-
// GET fallback endpoint
126-
.get('*', (req, res) => res.sendFile(path.join(__dirname, 'dist', 'index.html')));
125+
// If no other route is matched, serve up the index.html with a 404 status
126+
.use((req, res) => {
127+
res.status(404).sendFile(path.join(__dirname, 'dist', 'index.html'));
128+
});
127129

128130
/* Create HTTP server from app on port, and print welcome message */
129131
http.createServer(app)

0 commit comments

Comments
 (0)