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"
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/fqh123/p/12541595.html
今日推荐