Skip to content

Commit

Permalink
fix: can overwrite sdk header (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Feb 6, 2025
1 parent 165ea52 commit 9551215
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,18 @@ 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;
};

Expand Down
1 change: 0 additions & 1 deletion src/test/repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ test('should request with correct custom and unleash headers', (t) =>
storageProvider: new InMemStorageProvider(),
headers: {
randomKey,
'unleash-sdk': 'ignore',
'unleash-connection-id': 'ignore',
},
});
Expand Down

0 comments on commit 9551215

Please sign in to comment.