diff --git a/lib/alias.js b/lib/alias.js index 0e1b060..e005dbd 100644 --- a/lib/alias.js +++ b/lib/alias.js @@ -105,6 +105,9 @@ export default class Alias extends Now { console.log(`> ${chalk.bold(chalk.underline(alias))} is a custom domain.`); console.log(`> Verifying the DNS settings for ${chalk.bold(chalk.underline(alias))} (see ${chalk.underline('https://zeit.world')} for help)`); + const { domain, nameservers } = await this.getNameservers(alias); + if (this._debug) console.log(`> [debug] Found domain ${domain} and nameservers ${nameservers}`); + try { await this.verifyOwnership(alias); } catch (err) { @@ -113,8 +116,6 @@ export default class Alias extends Now { // in which case we attempt to correct the dns // configuration (if we can!) try { - const { domain, nameservers } = await this.getNameservers(alias); - if (this._debug) console.log(`> [debug] Found domain ${domain} and nameservers ${nameservers}`); if (isZeitWorld(nameservers)) { console.log(`> Detected ${chalk.bold(chalk.underline('zeit.world'))} nameservers! Configuring records.`); const record = alias.substr(0, alias.length - domain.length); @@ -158,6 +159,11 @@ export default class Alias extends Now { } } + if (!isZeitWorld(nameservers)) { + if (this._debug) console.log(`> [debug] Trying to register a non-ZeitWorld domain ${domain} for the current user`); + this.setupDomain(domain, { isExternal: true }); + } + console.log(`> Verification ${chalk.bold('OK')}!`); } diff --git a/lib/index.js b/lib/index.js index 4bac1be..3c231ba 100644 --- a/lib/index.js +++ b/lib/index.js @@ -372,12 +372,12 @@ export default class Now extends EventEmitter { } // _ensures_ the domain is setup (idempotent) - setupDomain (name) { + setupDomain (name, { isExternal } = {}) { return this.retry(async (bail, attempt) => { if (this._debug) console.time(`> [debug] #${attempt} POST /domains`); const res = await this._fetch('/domains', { method: 'POST', - body: { name } + body: { name, isExternal: !!isExternal } }); if (this._debug) console.timeEnd(`> [debug] #${attempt} POST /domains`);