mobile-check.js 389 Bytes
/**
 * 手机访问检测
 */
'use strict';
const querystring = require('querystring');

module.exports = () => {
    return (req, res, next) => {
        if (!req.xhr && req.isMobile) {
            return res.redirect(req.mobileUrl || res.locals.mobileRefer ||
                `//m.yohobuy.com${req.url}?${querystring.stringify(req.query)}`);
        }

        return next();
    };
};