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"
}
}
}
- 部署:
pm2 start npm --name "my-nuxt" -- run start