launchdarkly / js-client-sdk

LaunchDarkly Client-side SDK for Browser JavaScript
Other
109 stars 62 forks source link

Access to XMLHttpRequest at 'https://events.launchdarkly.com/events/bulk/6374af9a71e138110cdb10cd' from origin 'https://localhost:5001' has been blocked by CORS policy: Request header field request-context is not allowed by Access-Control-Allow-Headers in preflight response. #295

Closed ptldanielthompson closed 3 months ago

ptldanielthompson commented 7 months ago

I am getting this error in my console logs and its being sent to AppInsights it does not seem to effect the running of my launch darkly features. Just curious if there is anything I need to do to stop it

Access to XMLHttpRequest at 'https://events.launchdarkly.com/events/bulk/6374af9a71e138110cdb10cd' from origin 'https://localhost:5001' has been blocked by CORS policy: Request header field request-context is not allowed by Access-Control-Allow-Headers in preflight response.

It also happens in production not just my localhost development

"launchdarkly-react-client-sdk": "^3.0.9",
kinyoklion commented 7 months ago

Hello @ptldanielthompson,

This is going to affect the analytics and other features in the UI of LaunchDarkly. Information like context attributes, or data for experimentation, are delivered through this mechanism.

It soulds like something is adding a "request-context" header to the event payloads. This isn't something that the LaunchDarkly SDK does, and isn't a header that our endpoints accept.

I am not familiar with ApplicationInsights, but if its usage involves an SDK, then it may be that it is modifying requests to incorporate this header (from some searching it seems like it may be related to a cross origin correlations feature). Things like this sometimes happen with various APM tools.

So, first I would see if the issue goes away if you don't use ApplicationInsights locally. If it does, then you can work from that to determine how to prevent ApplicationInsights from modifying LaunchDarkly requests.

Thank you, Ryan

gdp2 commented 3 months ago

Hoping for an update as I am facing the same issue

kinyoklion commented 3 months ago

Hello @gdp2,

Currently there is no activity or anticipated activity for this ticket. As the SDK does not add a "request-context" to any headers. So identifying the code that is adding that header is the correct course of action.

Are you using azure/asp/appinsights? It seems like this functionality may be controlled by "RequestTrackingTelemetryModule" or some app insights configuration file.

If this header is required, then please contact our support. Reference this thread so they have context. Our endpoints do not accept that header, so there isn't anything the SDK can do.

Thanks, Ryan

ptldanielthompson commented 3 months ago

Thank you for the heads up. Its given me a new direction to search for a fix. I appreciate the answer.

gdp2 commented 3 months ago

ease contact our support. Reference this t

I am using Dynatrace for user monitoring.It adds some custom headers(x-dtpc,x-dtReferer) to launchdarkly's bulk api.

prabusampath007 commented 2 months ago

@ptldanielthompson, how did you fixed this issue? Can you please share the solution, we're also facing the similar kind of issue.