react 反向代理

1,892 阅读1分钟

webpack.config.js

devServer: {
    proxy: {
        '/api': {
            // 后端域名
            target: 'http://admintset.happymmall.com',
            changeOrigin: true
        }
    }   
}

react alias用法(起别名)

webpack.config.js
const path = require('path')
resolve: {
    alias: {
        page: path.resolve(__dirname, 'src/page')  // 相对路径
    }
}