Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve the problem of cross domain login failure. #203

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
@@ -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
@@ -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"
2 changes: 1 addition & 1 deletion src/gitment.js
Original file line number Diff line number Diff line change
@@ -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,
8 changes: 7 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -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