美文网首页
Vue-cli3.0配置proxy解决跨域问题

Vue-cli3.0配置proxy解决跨域问题

作者: ZONG丶 | 来源:发表于2020-10-10 11:26 被阅读0次
    devServer: {
            open: true, //是否自动弹出浏览器页面
            host: "localhost",
            port: '8080',
            proxy: {
                '/v1': {
                    target: 'https://www.xxx.com',   // 请求服务器根路径
                    changeOrigin: true,    // 是否跨域
                    ws: true,   // websocket
                    pathRewrite: {    // 重写路径: 当检测到请求地址里包含 /v1 时,将此路径进行跨域代理操作
                        '^/v1': 'https://www.xxx.com'
                    }
                }
            }
        }

相关文章

网友评论

      本文标题:Vue-cli3.0配置proxy解决跨域问题

      本文链接:https://www.haomeiwen.com/subject/adidpktx.html