Skip to content

Commit 0d05eeb

Browse files
committed
Merge remote-tracking branch 'origin/main' into mtewani/add-emulator-overlay
2 parents 0aede90 + 6a02778 commit 0d05eeb

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/auth": patch
3+
---
4+
5+
Fix issue where auth port wasn't properly set when setting up cookies in Firebase Studio.

packages/auth/src/core/auth/emulator.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { Endpoint } from '../../api';
2929
import { UserInternal } from '../../model/user';
3030
import { _castAuth } from './auth_impl';
3131
import { connectAuthEmulator } from './emulator';
32+
import * as Util from '@firebase/util';
3233

3334
use(sinonChai);
3435
use(chaiAsPromised);
@@ -38,8 +39,10 @@ describe('core/auth/emulator', () => {
3839
let user: UserInternal;
3940
let normalEndpoint: fetch.Route;
4041
let emulatorEndpoint: fetch.Route;
42+
let utilStub: sinon.SinonStub;
4143

4244
beforeEach(async () => {
45+
utilStub = sinon.stub(Util, 'pingServer');
4346
auth = await testAuth();
4447
user = testUser(_castAuth(auth), 'uid', 'email', true);
4548
fetch.setUp();
@@ -154,6 +157,19 @@ describe('core/auth/emulator', () => {
154157
);
155158
}
156159
});
160+
it('calls pingServer with port if specified', () => {
161+
connectAuthEmulator(auth, 'https://abc.cloudworkstations.dev:2020');
162+
expect(utilStub).to.have.been.calledWith(
163+
'https://abc.cloudworkstations.dev:2020'
164+
);
165+
});
166+
167+
it('calls pingServer with no port if none specified', () => {
168+
connectAuthEmulator(auth, 'https://abc.cloudworkstations.dev');
169+
expect(utilStub).to.have.been.calledWith(
170+
'https://abc.cloudworkstations.dev'
171+
);
172+
});
157173

158174
it('logs out a warning to the console', () => {
159175
sinon.stub(console, 'info');

packages/auth/src/core/auth/emulator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function connectAuthEmulator(
108108

109109
// Workaround to get cookies in Firebase Studio
110110
if (isCloudWorkstation(host)) {
111-
void pingServer(`${protocol}//${host}:${port}`);
111+
void pingServer(`${protocol}//${host}${portStr}`);
112112
updateEmulatorBanner('Auth', true);
113113
}
114114
}

0 commit comments

Comments
 (0)