From d738f8d84af09338693e11be167748ab7d1050bb Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Fri, 27 May 2016 18:17:10 -0700 Subject: [PATCH] add user-agent to all outgoing requests --- lib/index.js | 2 ++ lib/ua.js | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 lib/ua.js diff --git a/lib/index.js b/lib/index.js index 6495c1c..7183f6c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,7 @@ import bytes from 'bytes'; import chalk from 'chalk'; import getFiles from './get-files'; +import ua from './ua'; import hash from './hash'; import retry from 'async-retry'; import Agent from './agent'; @@ -280,6 +281,7 @@ export default class Now extends EventEmitter { _fetch (_url, opts = {}) { opts.headers = opts.headers || {}; opts.headers.authorization = `Bearer ${this._token}`; + opts.headers['user-agent'] = ua; return this._agent.fetch(_url, opts); } } diff --git a/lib/ua.js b/lib/ua.js new file mode 100644 index 0000000..6153350 --- /dev/null +++ b/lib/ua.js @@ -0,0 +1,4 @@ +import os from 'os'; +import { version } from '../package'; + +export default `now ${version} node-${process.version} ${os.platform()} (${os.arch()})`;