私はたくさんのミドルウェアを持っています。最初app.use
に、プロセスが強要されているかどうかをテストします。そうであれば、静的/index.html
ファイルを送信して、ユーザーのブラウザーを にリダイレクトします"/#" + req.url
。
例えば:
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(...))
今のところ、index.html を現在の URL に送信するだけです。将来のミドルウェアを台無しにすることなく、それらを「/」にリダイレクトしてindex.htmlを提供するにはどうすればよいですか。