方法定义, 设置 1000 * 60 * 5 超时时间不生效, 还是默认拦截器的1000*60:
export function cmdActiveVsi (data) {
return Vue.prototype.$api.post(baseUrl + '/com/mpls/v1/execVsiConfig', data, 1000 * 60 * 5)
}
这是拦截器的配置:
let instance = axios.create({
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
timeout: 1000 * 60
})
$api.post
function post (url, data, timeout) {
if (timeout) {
return instance({
url: url,
method: 'post',
timeout: timeout,
data: data
})
}
return instance({
url: url,
method: 'post',
data: data
})
}
猜测一下可能性。
本地OK,说明本地开发没有防火墙,没有任何网络设置
线上NG,这需要看网络拓扑,有没有防火墙,有没有负载平衡(硬件做的,还是软件做的),有没有API网关做请求转发。
所有的因素都要考虑进去,各种规则都要查一下,是否有链接超时的设定,有一个设定不OK,你在axios里面的设定,就不起作用。axios的设定只是一厢情愿。
已参与了 SegmentFault 思否社区 10 周年「问答」打卡 ,欢迎正在阅读的你也加入。