Skip to content

Commit

Permalink
Don't send empty GMPID header (#4810)
Browse files Browse the repository at this point in the history
* Don't send empty GMPID header

* Create five-wolves-tickle.md
  • Loading branch information
schmidt-sebastian authored Apr 21, 2021
1 parent 3f37021 commit c658836
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-wolves-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/firestore": patch
---

Don't send empty X-Firebase-GMPID header when AppId is not set in FirebaseOptions
4 changes: 3 additions & 1 deletion packages/firestore/src/platform/node/grpc_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ function createMetadata(
}
}
}
metadata.set('X-Firebase-GMPID', appId);
if (appId) {
metadata.set('X-Firebase-GMPID', appId);
}
metadata.set('X-Goog-Api-Client', X_GOOG_API_CLIENT_VALUE);
// This header is used to improve routing and project isolation by the
// backend.
Expand Down
4 changes: 3 additions & 1 deletion packages/firestore/src/remote/rest_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ export abstract class RestConnection implements Connection {
token: Token | null
): void {
headers['X-Goog-Api-Client'] = X_GOOG_API_CLIENT_VALUE;
headers['X-Firebase-GMPID'] = this.databaseInfo.appId;

// Content-Type: text/plain will avoid preflight requests which might
// mess with CORS and redirects by proxies. If we add custom headers
// we will need to change this code to potentially use the $httpOverwrite
// parameter supported by ESF to avoid triggering preflight requests.
headers['Content-Type'] = 'text/plain';

if (this.databaseInfo.appId) {
headers['X-Firebase-GMPID'] = this.databaseInfo.appId;
}
if (token) {
for (const header in token.authHeaders) {
if (token.authHeaders.hasOwnProperty(header)) {
Expand Down

0 comments on commit c658836

Please sign in to comment.