Skip to content

Commit 86a70f9

Browse files
committed
get SDK_VERSION value correctly
1 parent 182d406 commit 86a70f9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/firestore/src/remote/rest_connection.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ RPC_NAME_URL_MAPPING['Commit'] = 'commit';
3939
RPC_NAME_URL_MAPPING['RunQuery'] = 'runQuery';
4040

4141
const RPC_URL_VERSION = 'v1';
42-
const X_GOOG_API_CLIENT_VALUE = 'gl-js/ fire/' + SDK_VERSION;
4342

43+
// SDK_VERSION is updated to different value at runtime depending on the entry point,
44+
// so we need to get its value when we need it in a function.
45+
function getGoogApiClientValue() {
46+
return 'gl-js/ fire/' + SDK_VERSION;
47+
}
4448
/**
4549
* Base class for all Rest-based connections to the backend (WebChannel and
4650
* HTTP).
@@ -118,7 +122,7 @@ export abstract class RestConnection implements Connection {
118122
headers: StringMap,
119123
token: Token | null
120124
): void {
121-
headers['X-Goog-Api-Client'] = X_GOOG_API_CLIENT_VALUE;
125+
headers['X-Goog-Api-Client'] = getGoogApiClientValue();
122126

123127
// Content-Type: text/plain will avoid preflight requests which might
124128
// mess with CORS and redirects by proxies. If we add custom headers

0 commit comments

Comments
 (0)