Skip to content

Commit 6a02778

Browse files
authored
Fix Auth Port for Firebase Studio (#8998)
1 parent 080a90d commit 6a02778

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

.changeset/lemon-tomatoes-breathe.md

+5
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

+16
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function connectAuthEmulator(
103103

104104
// Workaround to get cookies in Firebase Studio
105105
if (isCloudWorkstation(host)) {
106-
void pingServer(`${protocol}//${host}:${port}`);
106+
void pingServer(`${protocol}//${host}${portStr}`);
107107
}
108108
}
109109

0 commit comments

Comments
 (0)