Reputation: 335
I'm trying to retrieve audio/image file from db.
app.use(restrictMiddleware());
Tho, because of the Route Restrict: It doesn't work. The question is, is there any other way to retrieve audio/image file from db so that it won't conflict with Authentication Route Restriction?
self.get = function (req, res) {
let params = [
req.params.record_id,
];
db.query(`SELECT * ...`, params).then((data) => {
console.log('result: ', data.rows.length);
res.contentType('audio/mpeg');
res.send(data.rows[0].audiofile);
}).catch((err) => {
res.status(500).end("Error:" + err);
});
};
Upvotes: 0
Views: 275
Reputation: 82096
Various ways of tackling this:
app.use(restrictMiddleware())
Router
and only apply the restrictMiddleware
to that, that way you can add non-secure routes easilyrestrictMiddleware
and skip when appropriate (not the nicest, but would do the job)Upvotes: 1