diff --git a/.gitignore b/.gitignore index 5897cd8..e23b9c1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ node_modules dist test/config.js -index.html \ No newline at end of file +index.html +/nbproject/private/ \ No newline at end of file diff --git a/package.json b/package.json index d7a066a..2444f34 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ }, "homepage": "https://github.com/imsun/gitment", "scripts": { - "build": "babel src --out-dir dist --ignore test.js --source-maps & NODE_ENV=production webpack --config webpack.config.js --progress --profile --colors", + "build": "babel src --out-dir dist --ignore test.js --source-maps & cross-env NODE_ENV=production webpack --config webpack.config.js --progress --profile --colors", "dev": "webpack-dev-server --config webpack.dev.config.js --host 0.0.0.0 --progress --profile --colors" }, "devDependencies": { @@ -32,6 +32,7 @@ "webpack-dev-server": "^2.4.2" }, "dependencies": { + "cross-env": "^6.0.3", "mobx": "^3.1.7" }, "license": "MIT" diff --git a/src/gitment.js b/src/gitment.js index 06fe17a..62fc82d 100644 --- a/src/gitment.js +++ b/src/gitment.js @@ -99,7 +99,7 @@ class Gitment { }, options) this.state.user.isLoggingIn = true - http.post('https://gh-oauth.imsun.net', { + http.post('https://gitment.jermey.cn/login/oauth/access_token', { code, client_id, client_secret, diff --git a/src/utils.js b/src/utils.js index 69de733..b2488f0 100644 --- a/src/utils.js +++ b/src/utils.js @@ -66,7 +66,7 @@ function ajaxFactory(method) { }) req.open(method, url, true) - req.setRequestHeader('Accept', 'application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json') + if (token) { req.setRequestHeader('Authorization', `token ${token}`) } @@ -74,6 +74,12 @@ function ajaxFactory(method) { body = JSON.stringify(data) req.setRequestHeader('Content-Type', 'application/json') } + if(apiPath=='https://gitment.jermey.cn/login/oauth/access_token'){ + req.setRequestHeader('Accept','application/json') + } + else{ + req.setRequestHeader('Accept', 'application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json') + } req.send(body) return p