chatgpt登录出现获取您的 SSO 信息时出错解决方案
阅读大约需要1分钟。
解决方案
// 原始的 fetch 函数
const originalFetch = window.fetch;
// 修改后的 fetch 函数
window.fetch = new Proxy(originalFetch, {
apply: function (target, thisArg, argumentsList) {
const [url, options] = argumentsList;
// 解析 URL 以检查是否是特定的 API 请求
const parsedUrl = new URL(url, window.location.origin);
// /public-api/get_user_connection_info
console.log(`parsedUrl.pathname = ${parsedUrl.pathname}`)
const checkpathName = parsedUrl.pathname.includes('get_user_connection_info')
if (checkpathName) {
// 如果是特定的 API 请求,直接返回预设的响应
return Promise.resolve({
ok: true,
json: () => Promise.resolve({
"connections": [],
"must_use_enterprise_sso": false
})
});
} else {
console.log(`originalFetch url = ${url}`)
// 否则,调用原始的 fetch 函数
return target.apply(thisArg, argumentsList);
}
}
});
直接在每个网页之前使用这个hook,先拦截返回响应即可。
有时候真的烦。
所属分类:
前端
文章标签:
#js
#chatgpt