Closed githublaohu closed 9 months ago
jsdom 库 强制检查了跨域
// don't send the real request if we aren't allowed to use the headers if (!validCORSPreflightHeaders(xhr, resp, flag, properties)) { setResponseToNetworkError(xhr); return; }
是字节租户的同学吗?内部对域名做了限制,看一下这篇云文档:字节自建应用调用飞书服务端OpenAPI改造手册
可以提供链接吗? Java 可以调用,nodejs 调用失败。
可以提供链接吗? Java 可以调用,nodejs 调用失败。
飞书私聊下我?mazhe.nerd
只能有手机号 与邮箱添加....
或则提供二维码,可以吗?
只能有手机号 与邮箱添加....
mazhe.nerd@bytedance.com
麻烦,通过下申请好友请求
麻烦,通过下申请好友请求
我这边收不到请求;如果不是字节租户的同学上述方法可能不适用;可以提供一个最小复现化demo我这边排查下嘛?
有类似的微信沟通群吗?
有类似的微信沟通群吗?
没有;通过github issue机制来解决问题。同学先用最小demo复现一下?
只是做了简单的非常
class FeishuProvider {
client: lark.Client;
constructor() {
this.client = new lark.Client({
appId: "cli",
appSecret: "C",
});
}
sendMessage(receive_id: string, msg_type: string, content: string) {
this.client.im.message
.create({
data: {
receive_id: receive_id,
msg_type: msg_type,
content: content,
},
params: {
receive_id_type: "chat_id",
},
})
.then((data) => {
console.log("发送成功");
})
.catch((e) => {
console.log("发送失败");
});
}
}
const data = {
service_name: "kemon-next",
IP: "127.0.0.1",
start_time: new Date().toLocaleString(),
start_up_time: 3,
environment: env.NODE_ENV,
error: error,
status: error != undefined ? "success" : "fail",
};
feishu.sendMessage(
"oc",
"interactive",
JSON.stringify(data),
);
OK;sdk的版本是1.23.0吧
我这边试了一下是OK的,看上面报错是不是系统开了什么代理,导致open.feishu.cn的请求都挂了;可以试下不用sdk,用axios裸调用一下这个获取token的api看看能不能调通?:https://open.feishu.cn/document/server-docs/authentication-management/access-token/tenant_access_token_internal
最新版本 1.23.0... 还是异常
TypeError: Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined. at TokenManager.<anonymous> (/leaning/work/temp/kemon/.next/server/chunks/eef6e_@larksuiteoapi_node-sdk_es_index_a9f269.js:51011:21) at Generator.next (<anonymous>) at fulfilled (/leaning/work/temp/kemon/.next/server/chunks/eef6e_@larksuiteoapi_node-sdk_es_index_a9f269.js:86:32) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {stack: "TypeError: Cannot destructure property 'tenant_acc…jections (node:internal/process/task_queues:95:5)", message: "Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined."}
请问没有问题。依赖库进行检查,
同的哈。
POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal
Content-Type: multipart/form-data
{
"app_id": "cli",
"app_secret": "1"
}
返回的结果
{
"code": 0,
"expire": 7200,
"msg": "ok",
"tenant_access_token": "t-g10435b9BNTGEEOLG5EQHDPCHWZAFJ5DMT4VAWWR"
}
奇怪,加一下这个开发者互助交流群,艾特一下mazhe.nerd,群里沟通下: 邀请你加入飞书群,快点击https://go.feishu.cn/join-chat/58fr62a3-ae11-478c-b4fe-e2df2aacbdac加入吧!
代码 (/leaning/work/hyperimagine/kemon-next/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:377:12)
at Request.emit (node:events:514:28)
at Request.emit (node:domain:488:12)
at Request._processResponse (/leaning/work/hyperimagine/kemon-next/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:228:12)
at ClientRequest. (/leaning/work/hyperimagine/kemon-next/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:101:12)
at Object.onceWrapper (node:events:629:26)
at ClientRequest.emit (node:events:514:28)
at ClientRequest.emit (node:domain:488:12)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:693:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
at TLSSocket.socketOnData (node:_http_client:535:22)
at TLSSocket.emit (node:events:514:28)
at TLSSocket.emit (node:domain:488:12)
at addChunk (node:internal/streams/readable:545:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
at TLSSocket.Readable.push (node:internal/streams/readable:375:5)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
type: 'XMLHttpRequest'
}
this.client = new lark.Client({ appId: this.appId, appSecret: this.appSecret, });
异常(node:1178221) Warning: Accessing non-existent property 'splice' of module exports inside circular dependency (Use
node --trace-warnings ...` to show where the warning was created) (node:1178221) Warning: Accessing non-existent property 'splice' of module exports inside circular dependency (node:1178221) Warning: Accessing non-existent property 'splice' of module exports inside circular dependency (node:1178221) Warning: Accessing non-existent property 'splice' of module exports inside circular dependency console.error Error: Cross origin http://localhost forbidden at dispatchError (/leaning/work/hyperimagine/kemon-next/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:63:19) at validCORSHeaders (/leaning/work/hyperimagine/kemon-next/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:75:5) at validCORSPreflightHeaders (/leaning/work/hyperimagine/kemon-next/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:89:8) at Request.console.log
Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined. TypeError: Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined. at TokenManager. (/next/node_modules/.pnpm/@larksuiteoapi+node-sdk@1.23.0/node_modules/@larksuiteoapi/node-sdk/lib/index.js:56849:21)
at Generator.next ()
at fulfilled (/next/node_modules/.pnpm/@larksuiteoapi+node-sdk@1.23.0/node_modules/@larksuiteoapi/node-sdk/lib/index.js:67:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
定位1: this.appId , this.appSecret 这两个数据已经传过去了。
const { tenant_access_token, expire } = yield this.httpInstance .post(${this.domain}/open-apis/auth/v3/tenant_access_token/internal
, { app_id: this.appId, app_secret: this.appSecret, }) .catch((e) => { this.logger.error(e); }); ` 定位2:function validCORSHeaders(xhr, response, flag, properties, origin) { const acaoStr = response.headers["access-control-allow-origin"]; const acao = acaoStr ? acaoStr.trim() : null; if (acao !== "*" && acao !== origin) { properties.error = "Cross origin " + origin + " forbidden"; dispatchError(xhr); return false; } const acacStr = response.headers["access-control-allow-credentials"]; const acac = acacStr ? acacStr.trim() : null; if (flag.withCredentials && acac !== "true") { properties.error = "Credentials forbidden"; dispatchError(xhr); return false; } return true; }