Azure Applications Insights节点js模块不工作- Fetch API无法加载错误

Azure Applications Insights node js module not working - Fetch API cannot load error

本文关键字:API Fetch 错误 加载 工作 Insights Applications 节点 js 模块 Azure      更新时间:2023-09-26

我正在尝试将npm的应用程序洞察模块(https://www.npmjs.com/package/applicationinsights)集成到我的React js应用程序中。

我这样做的来源是:

import appInsights from 'applicationinsights';
appInsights.setup(applicationInsightsKey).start();

我得到的问题是,在我的Chrome开发人员工具,我可以看到一个飞行前的请求https://dc.services.visualstudio.com/v2/track。但是在控制台中,我可以看到以下错误:

"取回API无法加载https://dc.services.visualstudio.com/v2/track。请求报头字段内容编码不被允许pre - flight响应中的Access-Control-Allow-Headers。"

你知道如何解决这个问题吗?

你正在使用的node.js模块是node.js服务器的AI SDK。由于React js应用程序是javascript中的客户端应用程序,因此在技术上它们是不同的。

请尝试使用ApplicationInsights-JS。

此外,您可以参考https://azure.microsoft.com/en-us/documentation/articles/app-insights-web-track-usage/获取更多信息。