img
別のページへのリダイレクトで src 値を指定しても問題ありませんか?
ビューでは、私は持っていますimg
:
<img src='/images/fileName'/>
app.js 内
app.get('/images/:fileName', subject.image);
これは私のルートです:
exports.image = function(req, res){
var fileName = req.fileName;
fs.exists(fileName, function(exists){
if (exists) {
res.sendfile(imagePath);
}else{
res.redirect('http://gravatar.com/avatar/_some_hash');
}
});
}
私のコードは動作しますがres.redirect
、画像が存在しない場合でも使用できますか?
ありがとう