如何处理nodejs环境中的用户代理? [英] How to handle user-agent in nodejs environment?
本文介绍了如何处理nodejs环境中的用户代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开始使用包ua-parser,但是创建者太忙了,不能修改或提交... npm ua-parser是过时的,需要从github直接下载。有人知道其他好的包,如ua-parser是更新,可以与expressjs一起使用?或者有一种方法来处理expressjs?
I start to using the package "ua-parser" but the creator is too busy to mantain or commit... the npm ua-parser is outdate, and need to download directly from github. Someone know about other good package like ua-parser that is updated and can be used with expressjs? Or have a way to handle just with expressjs?
推荐答案
你看过:
或者,编写自己的中间件:
Or, write your own middleware:
app.use(function(req, res, next) {
res.locals.ua = req.get('User-Agent');
next();
});
参考:从内部获取用户代理
这篇关于如何处理nodejs环境中的用户代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文