diff --git a/CHANGELOG.md b/CHANGELOG.md index 758d6004a50..5ad56e50fd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,4 @@ - Release Firestore emulator v1.11.9: Fixes != and not-in operators. - Add endpoints to enable/disable background triggers in the Cloud Functions emulator. - Fixes `TypeError` that arises when trying to deploy with Firebase Hosting targets that don't exist in the project's firebase.json (#1232). +- Updates `firebase hosting:channel:delete` to remove the channel from the authorized domains list. diff --git a/src/commands/hosting-channel-delete.ts b/src/commands/hosting-channel-delete.ts index a48efd36dae..9c65925b5e3 100644 --- a/src/commands/hosting-channel-delete.ts +++ b/src/commands/hosting-channel-delete.ts @@ -1,7 +1,7 @@ import { bold, underline } from "cli-color"; import { Command } from "../command"; -import { deleteChannel, normalizeName } from "../hosting/api"; +import { deleteChannel, normalizeName, getChannel, removeAuthDomain } from "../hosting/api"; import { requirePermissions } from "../requirePermissions"; import * as getProjectId from "../getProjectId"; import * as requireConfig from "../requireConfig"; @@ -33,6 +33,7 @@ export default new Command("hosting:channel:delete ") const siteId = options.site || (await getInstanceId(options)); channelId = normalizeName(channelId); + const channel = await getChannel(projectId, siteId, channelId); let confirmed = Boolean(options.force); if (!confirmed) { @@ -50,6 +51,9 @@ export default new Command("hosting:channel:delete ") } await deleteChannel(projectId, siteId, channelId); + if (channel) { + await removeAuthDomain(projectId, channel.url); + } logLabeledSuccess( "hosting:channels", diff --git a/src/hosting/api.ts b/src/hosting/api.ts index fe0e787ab67..5df5632afcc 100644 --- a/src/hosting/api.ts +++ b/src/hosting/api.ts @@ -373,6 +373,21 @@ export async function addAuthDomain(project: string, url: string): Promise { + const domains = await getAuthDomains(project); + if (!domains.length) { + return domains; + } + const targetDomain = url.replace("https://", ""); + const authDomains = domains.filter((domain: string) => domain != targetDomain); + return updateAuthDomains(project, authDomains); +} + /** * Constructs a list of "clean domains" * by including all existing auth domains