Skip to content
On this page

配置代理

在本地起服务发起联调的时候,可能会遇到跨域请求,webpack可启动本地的代理

javascript
// webpack-dev-server 相关配置 https://webpack.js.org/configuration/dev-server/
    devServer: {
            // host: 'localhost',
            host: "0.0.0.0",
            port: 8000, // 端口号
            https: false, // https:{type:Boolean}
            open: true, //配置自动启动浏览器  http://172.16.1.12:7071/rest/mcdPhoneBar/ 
            hotOnly: true, // 热更新
            // proxy: 'http://localhost:8000'   // 配置跨域处理,只有一个代理
            proxy: { //配置自动启动浏览器
                "/production/*": {
                    target: "http://172.16.1.12:7071",
                    changeOrigin: true,
                    // ws: true,//websocket支持
                    secure: false
                },
                "/test/*": {
                    target: "http://172.16.1.12:2018",
                    changeOrigin: true,
                    //ws: true,//websocket支持
                    secure: false
                },
            }
    },
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
沪ICP备20006251号-1