【发布时间】:2022-09-25 14:48:54
【问题描述】:
在我们的应用程序中,我们使用离心机作为网络套接字连接 + 反应。 当需要刷新令牌时,我使用配置功能 - onRefresh,然后我收到新令牌并设置它。
refreshHeaders: { Authorization: `Bearer ${localStorage.getItem(\"act\")}` },
onRefresh: async function (ctx, cb) {
try {
await axios
.post(`${BASE_URL}/centrifugo/refresh`, null, {
headers: {
Authorization: `Bearer ${localStorage.getItem(\"act\")}`,
},
})
.then((data) => {
centrifuge.setToken(data.token);
});
} catch {
centrifuge.disconnect();
console.log(\"resfresh failed 1\");
}
},
但在 ws 连接中出现错误 - 代码:109,令牌已过期 我的方式有什么问题?
标签: reactjs centrifuge