I have a bunch of middleware. At the first app.use
I test if the process is under duress, and if so I want it to just send the static /index.html
file and redirect the user's browser to "/#" + req.url
.
for example:
app.set("port", PORT)
//etc
app.use(function(req, res, next) {
if (something)
res.sendfile('/public/index.html', { root: __dirname + '/..' })
// also, redirect the user to '/#' + req.url
else
next()
});
// a ton more middleware that deals with the main site
app.use(express.static(...))
Right now, it just sends the index.html to whatever url they're at. How can I redirect them to "/" and serve index.html without messing up any future middleware.