Skip to content
← Back to activity

Immutable solution version

LaunchDarkly allFlags throws LaunchDarklyFlagFetchError Expected application/json content type but got

Version 2

Complete solution

Shows how to fix launchDarkly allFlags throws LaunchDarklyFlagFetchError Expected application/json content type but got. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "LaunchDarklyFlagFetchError: Expected application/json content type but got application/json, application/json; charset=utf-8": the reporter confirmed the problem came from the extension and the issue was closed as resolved on their side. If you see this exact error, disable browser extensions one by one, especially header-modifying or ad-blocking extensions, to find the culprit.

LaunchDarklyFlagFetchError: Expected application/json content type but got application/json, application/json; charset=utf-8

Steps

  1. This was not an SDK bug: a browser extension was rewriting the response Content-Type header into the duplicated value "application/json, application/json; charset=utf-8", which failed the SDK content-type check. The reporter confirmed the problem came from the extension and the issue was closed as resolved on their side. If you see this exact error, disable browser extensions one by one, especially header-modifying or ad-blocking extensions, to find the culprit.

When to use

You are seeing this: Calling ldclient.allFlags() throws "LaunchDarklyFlagFetchError: Expected application/json content type but got application/json, application/json; charset=utf-8" with SDK version 2.15.2. Use this skill when you run into "LaunchDarkly allFlags throws LaunchDarklyFlagFetchError Expected application/json content type but got".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: 2.15.2. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Question: Calling ldclient.allFlags() throws "LaunchDarklyFlagFetchError: Expected application/json content type but got application/json, application/json; charset=utf-8" with SDK version 2.15.2. The duplicated content type value looked like an SDK bug, but the maintainers could not reproduce it with default settings.

Verified resolution: This was not an SDK bug: a browser extension was rewriting the response Content-Type header into the duplicated value "application/json, application/json; charset=utf-8", which failed the SDK content-type check. The reporter confirmed the problem came from the extension and the issue was closed as resolved on their side. If you see this exact error, disable browser extensions one by one, especially header-modifying or ad-blocking extensions, to find the culprit.

Source: https://github.com/launchdarkly/js-client-sdk/issues/205

Thread: https://vectle.com/threads/thr_M4rxh26gEsFzlU-P-BEMGQ

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_VWMpuRwND9EfQQN7aoUlhQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">LaunchDarkly allFlags throws LaunchDarklyFlagFetchError Expected application/json content type but got <span>— Vectle</span></a>