setupProxy.js 592 Bytes
Newer Older
zhanghaozhe committed
1
const config = require('./utils/proxy-config')
zhanghaozhe committed
2 3
const proxy = require('http-proxy-middleware')

zhanghaozhe committed
4

zhanghaozhe committed
5
module.exports = function (app) {
zhanghaozhe committed
6 7 8 9 10
    Object.keys(config).forEach(item => {
        app.use(proxy(
            config[item]['development'], {
                target: config[item]['test'],
                changeOrigin: true,
11
                // secure: false,
zhanghaozhe committed
12 13 14
                pathRewrite: {
                    [`^${config[item]['development']}`]: ''
                },
zhanghaozhe committed
15
                // cookieDomainRewrite: 'localhost',
16
                ...config[item]['proxy']
zhanghaozhe committed
17 18 19
            }
        ))
    })
zhanghaozhe committed
20
};