From cc3188f581c67222b153c3363f6a7755322f33af Mon Sep 17 00:00:00 2001 From: Alfred Gutierrez Date: Mon, 17 Apr 2023 19:26:37 -0700 Subject: [PATCH] fix(api): add user-agent to request. (#116) --- api/package-lock.json | 2 +- api/package.json | 2 +- api/src/parser/profile.js | 4 ++++ api/src/parser/stats.js | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/package-lock.json b/api/package-lock.json index a7952a9..6e61df9 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -1,6 +1,6 @@ { "name": "overwatch-api", - "version": "0.12.0", + "version": "0.13.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/api/package.json b/api/package.json index 7d608fa..0372749 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "overwatch-api", - "version": "0.12.0", + "version": "0.13.0", "description": "An Unoffical Overwatch API.", "main": "lib/index.js", "typings": "index.d.ts", diff --git a/api/src/parser/profile.js b/api/src/parser/profile.js index 0977372..690a323 100644 --- a/api/src/parser/profile.js +++ b/api/src/parser/profile.js @@ -7,9 +7,13 @@ const MAX_RETRIES = 3; // Get HTML from playoverwatch career page. function getHTML(platform, region, tag, callback) { const url = `https://overwatch.blizzard.com/en-us/career/${tag}/` + const ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:112.0) Gecko/20100101 Firefox/112.0'; const options = { uri: encodeURI(url), + headers: { + 'User-Agent': ua, + }, encoding: 'utf8' } return retryRequest(options, MAX_RETRIES, callback); diff --git a/api/src/parser/stats.js b/api/src/parser/stats.js index 4109f35..3e476c7 100644 --- a/api/src/parser/stats.js +++ b/api/src/parser/stats.js @@ -7,9 +7,13 @@ const MAX_RETRIES = 3; // Get HTML from playoverwatch career page. function getHTML(platform, region, tag, callback) { const url = `https://overwatch.blizzard.com/en-us/career/${tag}/` + const ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:112.0) Gecko/20100101 Firefox/112.0'; const options = { uri: encodeURI(url), + headers: { + 'User-Agent': ua, + }, encoding: 'utf8' } return retryRequest(options, MAX_RETRIES, callback);