nuxt项目如何设置代理接口

1、安装@gauseen/nuxt-proxy包依赖

cnpm install @gauseen/nuxt-proxy --save

2.设置nuxt.config.js

修改modules为
modules: [
    "@gauseen/nuxt-proxy"
]

3.增加 proxyTable属性

proxyTable: {
    "/api": {
        target: 'https://xxxxx.com',
        changeOrigin: true,
        ws: false,
        pathRewrite: {
           "^/api": "/api"
        }
    }
}

 

 

 

 

posted @ 2020-03-21 19:39  古墩古墩  Views(1885)  Comments(0Edit  收藏  举报