0

我使用 xmpp.js 库与技巧连接https://github.com/xmppjs/xmpp.js/tree/main/packages/client

const { client, xml } = require("@xmpp/client");
        
const xmpp = client({
service: `finesse12.ucce.ipcc`,
domain: `finesse12.ucce.ipcc`,
username: "username",
password: "password"
});
        
xmpp.on('online', async function (address) {
await xmpp.send(xml("presence"));
});

xmpp.start().catch(console.error);

这成功地在节点中创建了一个连接,但是当我尝试在浏览器中使用这个包时,它最终出现了这个错误

CORS 策略已阻止从源“http://localhost:8080”获取“https://finesse12.ucce.ipcc/.well-known/host-meta”的访问权限:否“Access-Control-Allow-” Origin' 标头存在于请求的资源上。如果不透明的响应满足您的需求,请将请求的模式设置为“no-cors”以获取禁用 CORS 的资源。http.js:8 GET https://finesse12.ucce.ipcc/.well-known/host-meta net::ERR_FAILED 404 xe.resolve@http.js:8 je@resolve.js:9(匿名)@index .js:11 (anonymous) @ index.js:77 Ce.r.connect @ index.js:69 e.start @ index.js:212 (anonymous) @ (index):53 错误:找不到兼容的传输。在 index.js:72:13

为了在浏览器端运行它,我缺少什么,因为包说它在浏览器中也受支持

4

0 回答 0