我正在尝试将 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/了解更多信息。
关于javascript - Azure 应用程序见解 Node js 模块无法正常工作 - Fetch API 无法加载错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40532058/