Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lemon-tomatoes-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/auth": patch
---

Fix issue where auth port wasn't properly set when setting up cookies in Firebase Studio.
16 changes: 16 additions & 0 deletions packages/auth/src/core/auth/emulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { Endpoint } from '../../api';
import { UserInternal } from '../../model/user';
import { _castAuth } from './auth_impl';
import { connectAuthEmulator } from './emulator';
import * as Util from '@firebase/util';

use(sinonChai);
use(chaiAsPromised);
Expand All @@ -38,8 +39,10 @@ describe('core/auth/emulator', () => {
let user: UserInternal;
let normalEndpoint: fetch.Route;
let emulatorEndpoint: fetch.Route;
let utilStub: sinon.SinonStub;

beforeEach(async () => {
utilStub = sinon.stub(Util, 'pingServer');
auth = await testAuth();
user = testUser(_castAuth(auth), 'uid', 'email', true);
fetch.setUp();
Expand Down Expand Up @@ -154,6 +157,19 @@ describe('core/auth/emulator', () => {
);
}
});
it('calls pingServer with port if specified', () => {
connectAuthEmulator(auth, 'https://abc.cloudworkstations.dev:2020');
expect(utilStub).to.have.been.calledWith(
'https://abc.cloudworkstations.dev:2020'
);
});

it('calls pingServer with no port if none specified', () => {
connectAuthEmulator(auth, 'https://abc.cloudworkstations.dev');
expect(utilStub).to.have.been.calledWith(
'https://abc.cloudworkstations.dev'
);
});

it('logs out a warning to the console', () => {
sinon.stub(console, 'info');
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/core/auth/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function connectAuthEmulator(

// Workaround to get cookies in Firebase Studio
if (isCloudWorkstation(host)) {
void pingServer(`${protocol}//${host}:${port}`);
void pingServer(`${protocol}//${host}${portStr}`);
}
}

Expand Down
Loading