Skip to content
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

Feature request: Implement scoped default headers for SDK client #111

Open
mgm1313 opened this issue Oct 5, 2024 · 0 comments
Open

Feature request: Implement scoped default headers for SDK client #111

mgm1313 opened this issue Oct 5, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mgm1313
Copy link

mgm1313 commented Oct 5, 2024

I'd like a straightforward way to set default headers for requests. This is important for us because we use headers like Accept-Language and User-Agent for analytical purposes, among other things.

The api could extend the one proposed in #110 :

export async function createAgent({
  domain,
  locale,
}: AgentProps) {
  const baseUrl = someLogicToDetermineBaseUrl(domain);
  const userAgent = getVersionString()

  const agent = new sdk.client({
    defaultConfiguration: {
      baseUrl: new URL(baseUrl),
      headers: {
        'Accept-Language': locale,
        'User-Agent': userAgent,
      }
    }
  });
  return agent;
}
@elmerbulthuis elmerbulthuis self-assigned this Oct 5, 2024
@elmerbulthuis elmerbulthuis added the enhancement New feature or request label Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants