diff --git a/src/request.ts b/src/request.ts index 5e7d230e..5cc7d422 100644 --- a/src/request.ts +++ b/src/request.ts @@ -83,9 +83,7 @@ export const buildHeaders = ({ head['User-Agent'] = appName; head['unleash-appname'] = appName; } - if (connectionId) { - head['unleash-connection-id'] = connectionId; - } + if (instanceId) { head['UNLEASH-INSTANCEID'] = instanceId; } @@ -98,11 +96,15 @@ export const buildHeaders = ({ if (specVersionSupported) { head['Unleash-Client-Spec'] = specVersionSupported; } - const version = details.version; - head['unleash-sdk'] = `unleash-client-node:${version}`; if (custom) { Object.assign(head, custom); } + // unleash-connection-id and unleash-sdk should not be overwritten + if (connectionId) { + head['unleash-connection-id'] = connectionId; + } + const version = details.version; + head['unleash-sdk'] = `unleash-client-node:${version}`; return head; }; diff --git a/src/test/repository.test.ts b/src/test/repository.test.ts index 306f4d0d..ad28ee5e 100644 --- a/src/test/repository.test.ts +++ b/src/test/repository.test.ts @@ -207,6 +207,8 @@ test('should request with correct custom and unleash headers', (t) => storageProvider: new InMemStorageProvider(), headers: { randomKey, + 'unleash-sdk': 'ignore', + 'unleash-connection-id': 'ignore', }, });