diff --git a/.changeset/five-wolves-tickle.md b/.changeset/five-wolves-tickle.md
new file mode 100644
index 00000000000..2fa76a34b87
--- /dev/null
+++ b/.changeset/five-wolves-tickle.md
@@ -0,0 +1,5 @@
+---
+"@firebase/firestore": patch
+---
+
+Don't send empty X-Firebase-GMPID header when AppId is not set in FirebaseOptions
diff --git a/packages/firestore/src/platform/node/grpc_connection.ts b/packages/firestore/src/platform/node/grpc_connection.ts
index 1056c6694bf..c217ec16658 100644
--- a/packages/firestore/src/platform/node/grpc_connection.ts
+++ b/packages/firestore/src/platform/node/grpc_connection.ts
@@ -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.
diff --git a/packages/firestore/src/remote/rest_connection.ts b/packages/firestore/src/remote/rest_connection.ts
index c52138e5fa2..0ed08673a91 100644
--- a/packages/firestore/src/remote/rest_connection.ts
+++ b/packages/firestore/src/remote/rest_connection.ts
@@ -119,7 +119,6 @@ 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
@@ -127,6 +126,9 @@ export abstract class RestConnection implements Connection {
     // 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)) {