diff --git a/src/git/github.js b/src/git/github.js index c68bd34c..12197a5a 100644 --- a/src/git/github.js +++ b/src/git/github.js @@ -43,7 +43,7 @@ module.exports = class Github extends Git { } getAuthHeaders(reqOpt) { - if (reqOpt.headers.Authorization && !reqOpt.headers.Authorization.includes('token')) { + if (reqOpt.headers && reqOpt.headers.Authorization && !reqOpt.headers.Authorization.includes('token')) { reqOpt.headers = { ...reqOpt.headers, Authorization: 'token ' + reqOpt.headers.Authorization }; } reqOpt.headers = { ...reqOpt.headers, 'User-Agent': this.owner }; diff --git a/src/git/gitlab.js b/src/git/gitlab.js index d8c85b12..a7e5a1f6 100644 --- a/src/git/gitlab.js +++ b/src/git/gitlab.js @@ -57,7 +57,7 @@ module.exports = class Gitlab extends Git { } getAuthHeaders(reqOpt) { - if (reqOpt.headers.Authorization && !reqOpt.headers.Authorization.includes('Bearer')) { + if (reqOpt.headers && reqOpt.headers.Authorization && !reqOpt.headers.Authorization.includes('Bearer')) { reqOpt.headers = { ...reqOpt.headers, Authorization: 'Bearer ' + reqOpt.headers.Authorization }; } return reqOpt;