UNPKG

dmp-cli

Version:

Dmp component's cli

32 lines (27 loc) 1.03 kB
const path = require('path') const { argv } = require('yargs') const defaultConfig = { debug: true, server: 'http://oss-cn-hangzhou.aliyuncs.com', cacheDir: 'tmp_cache', root: path.join(__dirname, '../'), proxyTable: { '/api': { target: argv.test ? 'https://dmp-test.mypaas.com.cn' : 'https://dmp.mypaas.com.cn', changeOrigin: true, //修改代理响应头cookie域名与开发域名一致,方便登录认证 // cookieDomainRewrite: 'localhost', onProxyRes(proxyRes, req) { const cookies = proxyRes.headers['set-cookie'] if (Array.isArray(cookies) && cookies.length > 0) { const hostname = req.headers.host const host = hostname ? hostname.slice(0, hostname.indexOf(':')) : 'localhost' const REG = /Domain\s*=\s*dmp(-test)?.mypaas.com.cn/ig const newDomain = `Domain=${host}` proxyRes.headers['set-cookie'] = cookies.map(d => d.replace(REG, newDomain)) } }, } } } module.exports = defaultConfig