MCPcopy
hub / github.com/caprover/caprover / removeCustomDomainForApp

Method removeCustomDomainForApp

src/datastore/AppsDataStore.ts:406–443  ·  view source on GitHub ↗
(appName: string, customDomainToRemove: string)

Source from the content-addressed store, hash-verified

404 }
405
406 removeCustomDomainForApp(appName: string, customDomainToRemove: string) {
407 const self = this
408
409 return this.getAppDefinition(appName).then(function (app) {
410 app.customDomain = app.customDomain || []
411
412 const newDomains = []
413 let removed = false
414 for (let idx = 0; idx < app.customDomain.length; idx++) {
415 if (
416 app.customDomain[idx].publicDomain === customDomainToRemove
417 ) {
418 removed = true
419 } else {
420 newDomains.push(app.customDomain[idx])
421 }
422 }
423
424 if (!removed) {
425 throw ApiStatusCodes.createError(
426 ApiStatusCodes.STATUS_ERROR_GENERIC,
427 `Custom domain ${customDomainToRemove} does not exist in ${appName}`
428 )
429 }
430
431 if (app.redirectDomain) {
432 if (`${app.redirectDomain}` === customDomainToRemove) {
433 app.redirectDomain = undefined
434 }
435 if (newDomains.length === 0) {
436 app.redirectDomain = undefined
437 }
438 }
439
440 app.customDomain = newDomains
441 return self.saveApp(appName, app)
442 })
443 }
444
445 addCustomDomainForApp(appName: string, customDomain: string) {
446 const self = this

Callers 1

removeCustomDomainMethod · 0.80

Calls 4

getAppDefinitionMethod · 0.95
pushMethod · 0.80
createErrorMethod · 0.80
saveAppMethod · 0.80

Tested by

no test coverage detected