Skip to content

Commit c282b7c

Browse files
committed
Moved emulator calculation to rest connection
1 parent 2646d94 commit c282b7c

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

packages/firestore/src/platform/browser/webchannel_connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class WebChannelConnection extends RestConnection {
7272
url: string,
7373
headers: StringMap,
7474
body: Req,
75-
_isUsingEmulator: boolean
75+
_forwardCredentials: boolean
7676
): Promise<Resp> {
7777
const streamId = generateUniqueDebugId();
7878
return new Promise((resolve: Resolver<Resp>, reject: Rejecter) => {

packages/firestore/src/platform/browser_lite/fetch_connection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class FetchConnection extends RestConnection {
4141
url: string,
4242
headers: StringMap,
4343
body: Req,
44-
isUsingEmulator: boolean
44+
forwardCredentials: boolean
4545
): Promise<Resp> {
4646
const requestJson = JSON.stringify(body);
4747
let response: Response;
@@ -52,7 +52,7 @@ export class FetchConnection extends RestConnection {
5252
headers,
5353
body: requestJson
5454
};
55-
if (isCloudWorkstation(new URL(url).host) && isUsingEmulator) {
55+
if (forwardCredentials) {
5656
fetchArgs.credentials = 'include';
5757
}
5858
response = await fetch(url, fetchArgs);

packages/firestore/src/remote/rest_connection.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { isCloudWorkstation } from '@firebase/util';
1819
import { SDK_VERSION } from '../../src/core/version';
1920
import { Token } from '../api/credentials';
2021
import {
@@ -98,12 +99,15 @@ export abstract class RestConnection implements Connection {
9899
};
99100
this.modifyHeadersForRequest(headers, authToken, appCheckToken);
100101

102+
const { host } = new URL(url);
103+
const forwardCredentials =
104+
isCloudWorkstation(host) && this.databaseInfo.isUsingEmulator;
101105
return this.performRPCRequest<Req, Resp>(
102106
rpcName,
103107
url,
104108
headers,
105109
req,
106-
this.databaseInfo.isUsingEmulator
110+
forwardCredentials
107111
).then(
108112
response => {
109113
logDebug(LOG_TAG, `Received RPC '${rpcName}' ${streamId}: `, response);
@@ -186,7 +190,7 @@ export abstract class RestConnection implements Connection {
186190
url: string,
187191
headers: StringMap,
188192
body: Req,
189-
isUsingEmulator: boolean
193+
_forwardCredentials: boolean
190194
): Promise<Resp>;
191195

192196
private makeUrl(rpcName: string, path: string): string {

0 commit comments

Comments
 (0)