Skip to content

[STREAM-63] - Add custom headers to all API requests if they're passed into config. #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2025

Conversation

maxwellmooney13
Copy link
Collaborator

No description provided.

@@ -75,7 +75,7 @@ export class Client extends EventEmitter {

constructor (options: IClientOptions) {
super();
this.http = new HttpClient();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Streaming Client spins up a HttpClient instance, it now passes in the customHeaders from the config (though perhaps we should check if it exists first?) so that the HttpClient can then use it at a later point

opts.customHeaders = {
...this.customHeaders,
...opts.customHeaders
};
Copy link
Collaborator Author

@maxwellmooney13 maxwellmooney13 May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thinking here (which Jon and I worked through) is that though we can't think of a reason why this would be the case, but if there is a scenario where we need to pass in a different value for customHeaders than what is passed in for the Streaming Client config, then we should use that passed in value over the config value which is hopefully what will happen here. Again, we can't think of a reason this would happen, but if someone passes in a different customHeaders, there would be a reason behind it so it needs to be honored.

…f customHeaders, added in HttpClientOptions to hopefully reduce the need of breaking changes in the future
@@ -671,8 +670,7 @@ export class Client extends EventEmitter {
method: 'post',
host: this.config.apiHost,
authToken: this.config.authToken,
logger: this.logger,
customHeaders: this.config.customHeaders
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed these because they get added in regardless in requestApi, so it seemed a bit redundant for the same customHeaders

@zservies
Copy link
Collaborator

Can we change the PR title? I'm not sure it makes sense. We're not checking for custom headers, we're just passing them along.

@zservies zservies changed the title [STREAM-63] - Added in check to assign customHeaders from config if none passed in [STREAM-63] - Add custom headers to all API requests if they're passed into config. Jun 2, 2025
@zservies zservies merged commit e91f6ff into develop Jun 2, 2025
1 check passed
@zservies zservies deleted the STREAM-63 branch June 2, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants