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

Is it a good idea to custom User-Agent of request header ? #8

Open
zhatongning opened this issue Nov 3, 2024 · 0 comments
Open

Is it a good idea to custom User-Agent of request header ? #8

zhatongning opened this issue Nov 3, 2024 · 0 comments

Comments

@zhatongning
Copy link

export function defaultHeaders(
  sdkKey: string,
  info: IInfo
): Headers {
  const {userAgentBase, version} = info.sdkData();

  const headers: Headers = {
    'Content-Type': 'application/json',
    'User-Agent': `${ userAgentBase ?? info.appType }/${ version }`,
    'Authorization': sdkKey
  };

  return headers;
}

Here is the implement of the defaultHeaders function.The field 'User-Agent' comes from the userAgentBase which is "Browser-Client-SDK" in most time concat the version.I met a question in Dingtalk H5 in which the fetch to server will fail because the customed User-Agent cause DingTalk agent throwing away the request body. May Dingtalk doesn't handle it friendly, and I also don't think it is good idea to customize User-Agent filed like this.

The "User-Agent" header field contains information about the user agent originating the request, which is often used by servers to help identify the scope of reported interoperability problems, to work around or tailor responses to avoid particular user agent
limitations, and for analytics regarding browser or operating system use.

it's from rfc. The customized User-Agent isn't consistent with the purpose " analytics regarding browser or operating system use"

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

No branches or pull requests

1 participant