diff --git a/src/cloudron.js b/src/cloudron.js index e450aba70..06d2b1748 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -273,13 +273,13 @@ async function prepareDashboardDomain(domain, auditSource) { if (settings.isDemo()) throw new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode'); - const domainObject = domains.get(domain); + const domainObject = await domains.get(domain); + if (!domain) throw new BoxError(BoxError.NOT_FOUND, 'No such domain'); const fqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject); const result = await apps.list(); - const conflict = result.filter(app => app.fqdn === fqdn); - if (conflict.length) throw new BoxError(BoxError.BAD_STATE, 'Dashboard location conflicts with an existing app'); + if (result.some(app => app.fqdn === fqdn)) throw new BoxError(BoxError.BAD_STATE, 'Dashboard location conflicts with an existing app'); const taskId = await tasks.add(tasks.TASK_SETUP_DNS_AND_CERT, [ constants.DASHBOARD_LOCATION, domain, auditSource ]); @@ -296,6 +296,8 @@ async function setDashboardDomain(domain, auditSource) { debug(`setDashboardDomain: ${domain}`); const domainObject = await domains.get(domain); + if (!domain) throw new BoxError(BoxError.NOT_FOUND, 'No such domain'); + await reverseProxy.writeDashboardConfig(domain); const fqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject);