How does express determine that the device type returns to the home page under different paths when the user accesses the primary domain name?

how does express determine the device type to return to the home page under different paths when the user accesses the primary domain name?
if you visit mobile phone and PC, visit www. respectively. The domain name .com returns a different index home page

Mar.07,2021

on node, you can use req.headers ['user-agent'] to match whether it is accessed on PC, for example:

router.get('/', function(req, res, next) {
  var agent = req.headers['user-agent'];
  var tpl = /Android|webOS|iPhone|iPod|BlackBerry/i.test(agent)? 'index' : 'index2';
  //index.htmlindex2.html
  res.render(tpl);
});
Menu