sub-domain.js
539 Bytes
/**
* 匹配subdomain
* @author: 杨延青<yanqing.yang@yoho.cn>
* @date: 2016/6/16
*/
'use strict';
module.exports = () => {
return (req, res, next) => {
console.log(req.subdomains)
if (req.subdomains.length) {
switch (req.subdomains[0]) {
case 'guang': // 逛
break;
default: // 其它(识别为品牌)
req.url = `/product/brand/${req.subdomains[0]}`;
break;
}
}
next();
};
};