Azure Applications Insights 节点 js 模块不工作 - Fetch API 无法加载错误
Azure Applications Insights node js module not working - Fetch API cannot load error
我正在尝试将 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 发出的预检请求。
但是在控制台中我可以看到以下错误:
"Fetch API cannot load https://dc.services.visualstudio.com/v2/track.
Request header field content-encoding is not allowed by
Access-Control-Allow-Headers in preflight response."
你知道我该如何解决这个问题吗?
您使用的node.js模块是Node.js服务器的AI SDK。由于 React js 应用程序是 javascript 中的客户端应用程序,从技术上讲它们是不同的。
请尝试使用ApplicationInsights-JS。
此外,您可以参考https://azure.microsoft.com/en-us/documentation/articles/app-insights-web-track-usage/了解更多信息。
我正在尝试将 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 发出的预检请求。 但是在控制台中我可以看到以下错误:
"Fetch API cannot load https://dc.services.visualstudio.com/v2/track. Request header field content-encoding is not allowed by Access-Control-Allow-Headers in preflight response."
你知道我该如何解决这个问题吗?
您使用的node.js模块是Node.js服务器的AI SDK。由于 React js 应用程序是 javascript 中的客户端应用程序,从技术上讲它们是不同的。
请尝试使用ApplicationInsights-JS。
此外,您可以参考https://azure.microsoft.com/en-us/documentation/articles/app-insights-web-track-usage/了解更多信息。