diff --git a/lib/login.js b/lib/login.js index 47e0631..19fdccc 100644 --- a/lib/login.js +++ b/lib/login.js @@ -5,7 +5,7 @@ import fetch from 'node-fetch'; import { stringify as stringifyQuery } from 'querystring'; import chalk from 'chalk'; -const URL = 'https://api.now.sh/registration'; +const URL = 'http://api-registration.now.sh'; const stdin = process.openStdin(); @@ -23,6 +23,10 @@ async function getVerificationToken (email) { const data = JSON.stringify({ email }); const res = await fetch(URL, { method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': Buffer.byteLength(data) + }, body: data }); @@ -72,8 +76,7 @@ async function register () { return { email, token: final }; } -export default function () { - return register().then((loginData) => { - return fs.writeFile(pathJoin(homedir(), '.now.json'), JSON.stringify(loginData)); - }); +export default async function () { + const loginData = await register(); + return fs.writeFile(pathJoin(homedir(), '.now.json'), JSON.stringify(loginData)); }