main.js
645 Bytes
const Express = require('express');
let router = Express.Router(); // eslint-disable-line
const rp = require('request-promise');
const env = global.env;
const pageCache = {};
let mainProxy = (req, res) => {
res.header('x-version', env.version);
res.header('cache-control', 'no-store');
if (pageCache[env.version]) {
return res.send(pageCache[env.version]);
}
return rp.get(`http://cdn.yoho.cn/yoho-shop-manage/${env.version}/index.html`).then(body => {
pageCache[env.version] = body;
res.send(body);
});
};
router.get('/', mainProxy);
router.get(/\.html$/, mainProxy);
module.exports = router;