-
Notifications
You must be signed in to change notification settings - Fork 37
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
Extend user agent only on backend #528
Conversation
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "@multiversx/sdk-core", | |||
"version": "13.14.0", | |||
"version": "13.14.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 13.14.2
(the other one has been used).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/networkProviders/userAgent.ts
Outdated
|
||
headers.setUserAgent(newUserAgent, true); | ||
} | ||
|
||
export function isBackend(): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some libraries say like this:
I was afraid that we somehow set the window property, but we don't:
💭
@@ -34,7 +34,9 @@ export class ApiNetworkProvider implements INetworkProvider { | |||
this.config = { ...defaultAxiosConfig, ...config }; | |||
this.backingProxyNetworkProvider = new ProxyNetworkProvider(url, proxyConfig); | |||
this.axios = getAxios(); | |||
extendUserAgent(this.userAgentPrefix, this.config); | |||
if (isBackend()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also hide if !isBackend()
within extendUserAgent()
or extendUserAgentIfAppropriate()
🙃
Check if it is backend to set userAgent only then
https://stackoverflow.com/questions/4224606/how-to-check-whether-a-script-is-running-under-node-js