...
|
...
|
@@ -7,6 +7,7 @@ const yohoLib = require('yoho-node-lib'); |
|
|
const pkg = require('./package.json');
|
|
|
const devtools = require('./doraemon/middleware/devtools');
|
|
|
const _ = require('lodash');
|
|
|
const uuid = require('uuid');
|
|
|
|
|
|
// 全局注册library
|
|
|
yohoLib.global(config);
|
...
|
...
|
@@ -98,6 +99,24 @@ exports.createApp = async(app) => { |
|
|
app.use(userMiddleware);
|
|
|
app.use(serverMiddleware);
|
|
|
|
|
|
app.use((req, res, next) => {
|
|
|
// 独立的 UDID
|
|
|
if (!req.cookies.udid || (req.yoho.isApp && req.query.udid)) {
|
|
|
let udid = uuid.v4();
|
|
|
|
|
|
if (req.yoho.isApp && req.query.udid) {
|
|
|
udid = req.query.udid;
|
|
|
}
|
|
|
|
|
|
res.cookie('udid', udid, {
|
|
|
domain: 'yohobuy.com',
|
|
|
expires: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000)
|
|
|
});
|
|
|
req.cookies.udid = udid;
|
|
|
}
|
|
|
next();
|
|
|
});
|
|
|
|
|
|
if (!app.locals.proEnv) {
|
|
|
app.use((req, res, next) => {
|
|
|
if (/cordova/.test(req.url)) {
|
...
|
...
|
|