在nuxt-config.js
中,为什么代理在对象模式下起作用而不在数组模式下起作用?
Works:将/ api / v2 / inventory / 3906代理到nitro.noxgroup.co.za/v2/inventory/3906
proxy: {
'/api': {
target: 'https://nitro.noxgroup.co.za',
pathRewrite: {
'^/api': '/'
}
}
},
“阵列模式”不起作用:另外,尝试代理货币兑换服务
proxy: [
{'/api': {
target: 'https://nitro.noxgroup.co.za',
pathRewrite: {
'^/api': '/'
}
}},
{'/api-currency': {
target: 'https://rate-exchange-1.appspot.com',
pathRewrite: {
'^/api-currency': '/'
}
}},
]
错误:
FATAL [HPM] Missing "target" option. Example: {target: "http://www.example.org"}
在阵列模式下,配置由阵列和字符串组成。如果您将路径与config一起使用,则其数组为:
[ path, { ...config } ]
不是对象
{ [path]: { ... config } }
示例:
proxy: [
['/api', {
target: 'https://nitro.noxgroup.co.za',
pathRewrite: {
'^/api': '/'
}
}],
['/api-currency', {
target: 'https://rate-exchange-1.appspot.com',
pathRewrite: {
'^/api-currency': '/'
}
}],
]