Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules

dist
test/config.js
index.html
index.html
/nbproject/private/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -32,6 +32,7 @@
"webpack-dev-server": "^2.4.2"
},
"dependencies": {
"cross-env": "^6.0.3",
"mobx": "^3.1.7"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/gitment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@ 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}`)
}
if (method !== 'GET' && method !== 'DELETE') {
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
Expand Down