-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot modify the request headers and cookies when using a custom endpoint #1545
Comments
Hi, there are a couple of things here
So having said above, let me provide an approach that you might be able to implement as we do understand the concerns you are talking about.
You don't need to call the base function as these helpers "wrap" the calls so the "real" function is still called after the hooked request. The implementations are here https://github.com/microsoft/ApplicationInsights-JS/blob/master/shared/AppInsightsCore/src/JavaScriptSDK/InstrumentHooks.ts |
I should add that the above will hook "ALL" XHR requests, so you should check the outbound URL to ensure that it's the endpoint you want to add the headers too. |
Thanks a lot for the fast and accurate response. The suggested change works perfectly. Just to complement the code, I've added the import with Maybe you can add one paragraph in the README about this? If you consider it not important to add it, then the issue can be closed. |
Added getSender method and addHeader method. And provided customHeaders configuration. |
v2.6.3 is now fully deployed |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I am using the AppInsights tracking in a React application. This is my setup
3.1. Secure authentication cookie
3.2. Special header config value that complements the cookie
With the current setup defined, my Application Insights tracking is not working, because I am not able to modify the outgoing request. I have found addTelemetryInitializer which gives me access to the request payload but I need to be able to configure the outgoing request, similar to how I am able to modify the fetch:
The text was updated successfully, but these errors were encountered: