diff --git a/.changeset/dull-nails-kneel.md b/.changeset/dull-nails-kneel.md new file mode 100644 index 00000000000..09403953549 --- /dev/null +++ b/.changeset/dull-nails-kneel.md @@ -0,0 +1,5 @@ +--- +'@firebase/functions': patch +--- + +Allow a custom path in Firebase functions custom domain diff --git a/packages/functions/src/service.test.ts b/packages/functions/src/service.test.ts index 1a43b32136f..bb29f9025fe 100644 --- a/packages/functions/src/service.test.ts +++ b/packages/functions/src/service.test.ts @@ -70,6 +70,11 @@ describe('Firebase Functions > Service', () => { assert.equal(service._url('foo'), 'https://mydomain.com/foo'); }); + it('correctly sets custom domain with path', () => { + service = createTestService(app, 'https://mydomain.com/functions'); + assert.equal(service._url('foo'), 'https://mydomain.com/functions/foo'); + }); + it('prefers emulator to custom domain', () => { const service = createTestService(app, 'https://mydomain.com'); connectFunctionsEmulator(service, 'localhost', 5005); diff --git a/packages/functions/src/service.ts b/packages/functions/src/service.ts index b70a5b1fe57..c5fe7fa8a85 100644 --- a/packages/functions/src/service.ts +++ b/packages/functions/src/service.ts @@ -122,7 +122,8 @@ export class FunctionsService implements _FirebaseService { // Resolve the region or custom domain overload by attempting to parse it. try { const url = new URL(regionOrCustomDomain); - this.customDomain = url.origin; + this.customDomain = + url.origin + (url.pathname === '/' ? '' : url.pathname); this.region = DEFAULT_REGION; } catch (e) { this.customDomain = null;