launchdarkly / js-client-sdk

LaunchDarkly Client-side SDK for Browser JavaScript
Other
111 stars 63 forks source link

LaunchDarkly not initializing if cookies are disabled #302

Open rrawat-dev opened 1 month ago

rrawat-dev commented 1 month ago

Hi Team,

Facing an issue in our web application where LaunchDarkly is not initializing if we reject "Accept Cookies" options in our application. No LaunchDarkly api calls or errors are shown in the console. Working fine if we choose "Accept Cookies" option.

let ldClient = LDClient.initialize(key, context);
ldClient.waitForInitialization(5).then(() => {
  featureFlags = ldClient.allFlags();
}).catch(err) {
  console.log(err);
};
kinyoklion commented 1 month ago

Hello @rrawat-dev,

The SDK itself does not use any cookies. There are some cookies, associated with the domain that it connects to by default.

It is unclear why this would have any impact on the SDK.

That said, we have alternative endpoints available:

  const client = initialize('sdk-key', context, {
    baseUrl: 'https://clientsdk.launchdarkly.com',
    streamUrl: 'https://clientstream.launchdarkly.com',
  });

You can try these and let me know if it impacts your situation.

Thank you, Ryan

rrawat-dev commented 1 month ago

Hi @kinyoklion,

For Incognito Mode/Cookie Accept scenario: Able to see https://clientsdk.launchdarkly.com calls in network panel

For Incognito Mode/Cookie Decline scenario: No https://clientsdk.launchdarkly.com calls in network panel, No error for launchdarkly in console