Expressjs question

Hi @Callum-OKane

The empty files are likely waiting for a response from the app, and eventually will time out.

Try adding a line like this to serve the files that don’t need processing or special routes …

app.use(express.static('public'));

Depending how your app folders are structured, this might be /app/page instead of public, or you may have multiple folders to serve.


app.use(function(req, res) {
if(res.status(500)) return res.sendFile("/app/errors/500.html");
if(res.status(404)) return res.sendFile("/app/errors/404.html");
})

Note that this sends no response for any other status, you may want to add a default response.

1 Like