/review- {title} - {id} のような動的なルートを作成しようとしていますが、エラーが発生した原因はわかりません。それを処理する。 私のクライアントの要件は上記のようなものですが、私はノードでうまくいかず、誰もが上記のようなルートを作る方法を提案してください。 また、このようなルートを/ review /:title /:id形式にする必要がある場合は、どうすればよいのでしょうか。ノードに動的パスを作成してjsを表現します
私がしようとしていますが、それは404ページに私をリダイレクトし、
server.js
this is working..
app.get('/review', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client/review.html'));
});
but not this one..
app.get('/review-*-*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client/review.html'));
});
Also not this one working
app.get('/review/*/*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client/review.html'));
});
This is 404 page which call evrytime while accessing dynamic pages
app.get('/*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client/404.html'));
});
あなたはこれに興味があるかもしれません:http://stackoverflow.com/questions/25623041/how-to-configure-dynamic- routes-with-express-js – DrakaSAN