Home Ask Login Register

Developers Planet

Your answer is one click away!

James Thurley February 2016

Application insights setAuthenticatedUserContext with API on another domain

I have Application Insights configured on both the front and back-end of my website, which operate on different sub-domains (let's say www.mydomain.com and api.mydomain.com).

The cookie containing the user information set by setAuthenticatedUserContext is stored by AI with the cookie domain set to www.mydomain.com. When I make a call to api.mydomain.com the cookie is not included, and therefore the credentials I set are not associated with any AI data logged by the API.

My API has Access-Control-Allow-Credentials set to true, and the front-end has withCreditials set to true on the XHR object.

Can I get AI to set a different cookie domain, or is there some other issue at play here stopping the user information reaching the API?

Update: I notice Google Analytics sets a cookie with the domain set simply to .mydomain.com, and this cookie information is included with calls to my API.


Alex Bulankou February 2016

This is not currently supported but there is an issue opened on GH for it: https://github.com/Microsoft/ApplicationInsights-JS/issues/64 Please continue monitoring GH link, we will provide an update soon. Thanks!

Post Status

Asked in February 2016
Viewed 3,121 times
Voted 14
Answered 1 times


Leave an answer

Quote of the day: live life