vue3 多服务器域名跨域代理和请求配置

多服务器域名的跨域配置:
同样是在vue.config.js文件中对devServer.proxy进行配置,如下:

复制代码
const {defineConfig} = require('@vue/cli-service')
module.exports = defineConfig({
    transpileDependencies: true,
    lintOnSave: false, //关闭eslint检查,
    devServer: {
        proxy: {
            //配置服务器地址一
            '/apis': {
                // target: 'http://xx.xx.xx.xx:8001', //lcoal 接口域名
                // target: 'http://xx.xx.xx.xx:7088', //dev 接口域名
                target: 'http://xx.xx.xx.xx:8088', //real 接口域名
                changeOrigin: true,             //是否跨域
                ws: true,                       //是否代理 websockets
                secure: true,                   //是否https接口
                pathRewrite: {                  //路径重置
                    '^/apis': ''
                }
            },
            //配置服务器地址二
            '/externalApis': {
                target: 'http://xx.xx.xx.xx:8000', //外部接口域名
                changeOrigin: true,             //是否跨域
                ws: true,                       //是否代理 websockets
                secure: true,                   //是否https接口
                pathRewrite: {                  //路径重置
                    '^/externalApis': ''
                }
            }
        }
    }

})
复制代码

 

posted @   苹果芒  阅读(716)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示