Skip to content

Commit 8d93780

Browse files
committed
Addressed comments
1 parent 55b1c0a commit 8d93780

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

packages/data-connect/src/network/fetch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export function dcFetch<T, U>(
5959
accessToken: string | null,
6060
appCheckToken: string | null,
6161
_isUsingGen: boolean,
62-
_callerSdkType: CallerSdkType
62+
_callerSdkType: CallerSdkType,
63+
_isUsingEmulator: boolean
6364
): Promise<{ data: T; errors: Error[] }> {
6465
if (!connectFetch) {
6566
throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');
@@ -84,10 +85,9 @@ export function dcFetch<T, U>(
8485
headers,
8586
signal
8687
};
87-
if (isCloudWorkstation(url)) {
88+
if (isCloudWorkstation(url) && _isUsingEmulator) {
8889
fetchOptions.credentials = 'include';
8990
}
90-
logDebug(`Making request out to ${url} with body: ${bodyStr}`);
9191

9292
return connectFetch(url, fetchOptions)
9393
.catch(err => {

packages/data-connect/src/network/transport/rest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class RESTTransport implements DataConnectTransport {
3636
private _accessToken: string | null = null;
3737
private _appCheckToken: string | null = null;
3838
private _lastToken: string | null = null;
39+
private _isUsingEmulator = false;
3940
constructor(
4041
options: DataConnectOptions,
4142
private apiKey?: string | undefined,
@@ -93,6 +94,7 @@ export class RESTTransport implements DataConnectTransport {
9394
}
9495
useEmulator(host: string, port?: number, isSecure?: boolean): void {
9596
this._host = host;
97+
this._isUsingEmulator = true;
9698
if (typeof port === 'number') {
9799
this._port = port;
98100
}
@@ -182,7 +184,8 @@ export class RESTTransport implements DataConnectTransport {
182184
this._accessToken,
183185
this._appCheckToken,
184186
this._isUsingGen,
185-
this._callerSdkType
187+
this._callerSdkType,
188+
this._isUsingEmulator
186189
)
187190
);
188191
return withAuth;
@@ -208,7 +211,8 @@ export class RESTTransport implements DataConnectTransport {
208211
this._accessToken,
209212
this._appCheckToken,
210213
this._isUsingGen,
211-
this._callerSdkType
214+
this._callerSdkType,
215+
this._isUsingEmulator
212216
);
213217
});
214218
return taskResult;

packages/database/src/api/Database.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ function repoManagerApplyEmulatorSettings(
9090
tokenProvider?: AuthTokenProvider
9191
): void {
9292
let ssl = false;
93-
let finalHost = hostAndPort;
94-
if (/^https:\/\//.test(finalHost)) {
93+
let host = hostAndPort;
94+
if (/^https:\/\//.test(host)) {
9595
ssl = true;
96-
finalHost = finalHost.substring(8);
96+
host = host.substring(8);
9797
}
98-
if (/^wss:\/\//.test(finalHost)) {
98+
if (/^wss:\/\//.test(host)) {
9999
ssl = true;
100-
finalHost = finalHost.substring(6);
100+
host = host.substring(6);
101101
}
102102
repo.repoInfo_ = new RepoInfo(
103-
finalHost,
103+
host,
104104
/* secure= */ ssl,
105105
repo.repoInfo_.namespace,
106106
repo.repoInfo_.webSocketOnly,

packages/util/src/url.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1-
export function isCloudWorkstation(url: string) {
2-
return url.endsWith('cloudworkstations.dev');
3-
}
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export function isCloudWorkstation(url: string): boolean {
19+
return url.endsWith('.cloudworkstations.dev');
20+
}

0 commit comments

Comments
 (0)