Skip to content

Commit 2ee2a90

Browse files
Allow a custom path in Firebase functions custom domain (#8441)
* Allow a custom path in Firebase functions custom domain * Add a test * Add changeset * Update packages/functions/src/service.ts Co-authored-by: Daniel La Rocque <[email protected]> --------- Co-authored-by: Daniel La Rocque <[email protected]>
1 parent 05c34c9 commit 2ee2a90

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.changeset/dull-nails-kneel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/functions': patch
3+
---
4+
5+
Allow a custom path in Firebase functions custom domain

packages/functions/src/service.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ describe('Firebase Functions > Service', () => {
7070
assert.equal(service._url('foo'), 'https://mydomain.com/foo');
7171
});
7272

73+
it('correctly sets custom domain with path', () => {
74+
service = createTestService(app, 'https://mydomain.com/functions');
75+
assert.equal(service._url('foo'), 'https://mydomain.com/functions/foo');
76+
});
77+
7378
it('prefers emulator to custom domain', () => {
7479
const service = createTestService(app, 'https://mydomain.com');
7580
connectFunctionsEmulator(service, 'localhost', 5005);

packages/functions/src/service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ export class FunctionsService implements _FirebaseService {
122122
// Resolve the region or custom domain overload by attempting to parse it.
123123
try {
124124
const url = new URL(regionOrCustomDomain);
125-
this.customDomain = url.origin;
125+
this.customDomain =
126+
url.origin + (url.pathname === '/' ? '' : url.pathname);
126127
this.region = DEFAULT_REGION;
127128
} catch (e) {
128129
this.customDomain = null;

0 commit comments

Comments
 (0)