Files
MyIP/tests/firebase-auth-proxy.test.js
T
Claude 1c3a36d253 Fix(auth): serve Firebase's auth handler from the site's own origin
The installed iOS PWA opens an out-of-scope authDomain in the system's
in-app browser view, whose storage the PWA's own webview cannot read,
so a redirect sign-in completed there never reached the app. The
frontend server and the Vite dev server now proxy /__/auth/* to
https://<project>.firebaseapp.com (common/firebase-auth-proxy.js),
mounted only when VITE_FIREBASE_PROJECT_ID is set, so with
VITE_FIREBASE_AUTH_DOMAIN set to the site's host the handler runs
in-scope, inside the PWA itself. .env.example documents the three keys
and the console-side requirements (authorized domain, OAuth callback at
https://<host>/__/auth/handler).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GbLTGMZ45MV78qd2tHoco
2026-10-05 15:02:01 +00:00

29 lines
1.1 KiB
JavaScript

// Spec for common/firebase-auth-proxy.js — the `/__/auth` proxy target.
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { FIREBASE_AUTH_PROXY_PATH, firebaseAuthProxyTarget } from '../common/firebase-auth-proxy.js';
describe('firebaseAuthProxyTarget()', () => {
it('returns null without a project id', () => {
assert.equal(firebaseAuthProxyTarget(undefined), null);
assert.equal(firebaseAuthProxyTarget(null), null);
assert.equal(firebaseAuthProxyTarget(''), null);
assert.equal(firebaseAuthProxyTarget(' '), null);
});
it('maps a project id onto its firebaseapp.com origin', () => {
assert.equal(firebaseAuthProxyTarget('my-project'), 'https://my-project.firebaseapp.com');
});
it('trims surrounding whitespace', () => {
assert.equal(firebaseAuthProxyTarget(' my-project \n'), 'https://my-project.firebaseapp.com');
});
});
describe('FIREBASE_AUTH_PROXY_PATH', () => {
it('is the Firebase Auth handler prefix', () => {
assert.equal(FIREBASE_AUTH_PROXY_PATH, '/__/auth');
});
});