Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(functions): Add regionOrCustomDomain option to useEmulator. #766

Merged
merged 2 commits into from
Dec 9, 2024
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/cuddly-baboons-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@capacitor-firebase/functions': minor
---

feat(functions): add `regionOrCustomDomain` option to `UseEmulatorOptions`
robingenz marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 5 additions & 4 deletions packages/functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ On Android, the cleartext traffic must be allowed. On the Capacitor configuratio

#### UseEmulatorOptions

| Prop | Type | Description | Default | Since |
| ---------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- |
| **`host`** | <code>string</code> | The emulator host without any port or scheme. Note when using a Android Emulator device: 10.0.2.2 is the special IP address to connect to the 'localhost' of the host computer. | | 6.1.0 |
| **`port`** | <code>number</code> | The emulator port. | <code>5001</code> | 6.1.0 |
| Prop | Type | Description | Default | Since |
| -------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- |
| **`host`** | <code>string</code> | The emulator host without any port or scheme. Note when using a Android Emulator device: 10.0.2.2 is the special IP address to connect to the 'localhost' of the host computer. | | 6.1.0 |
| **`port`** | <code>number</code> | The emulator port. | <code>5001</code> | 6.1.0 |
| **`regionOrCustomDomain`** | <code>string</code> | one of: a) The region the callable functions are located in (ex: us-central1) b) A custom domain hosting the callable functions (ex: https://mydomain.com) | | |


### Type Aliases
Expand Down
7 changes: 7 additions & 0 deletions packages/functions/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,11 @@ export interface UseEmulatorOptions {
* @example 5001
*/
port?: number;
/**
* The region the callable functions are located in or a custom domain hosting the callable functions.
*
* @example 'us-central1'
* @example 'https://mydomain.com'
*/
regionOrCustomDomain?: string;
}
2 changes: 1 addition & 1 deletion packages/functions/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class FirebaseFunctionsWeb
}

public async useEmulator(options: UseEmulatorOptions): Promise<void> {
const functions = getFunctions();
const functions = getFunctions(undefined, options.regionOrCustomDomain);
const port = options.port || 5001;
connectFunctionsEmulator(functions, options.host, port);
}
Expand Down