Skip to content

Commit 17d5df7

Browse files
committed
Explicitly check for subdomain isolation to make sure all URLs work
Fixes #174
1 parent 1ead6f8 commit 17d5df7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

graphql/enterprise/index.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,22 @@ <h3>Create a <a href="https://help.github.com/articles/creating-a-personal-acces
170170
// as long as it returns a Promise or Observable.
171171
function graphQLFetcher(graphQLParams) {
172172
// Determine the API URL for this GitHub Enterprise server
173-
const hostnames = location.hostname.split('.')
174-
const apiHost = location.protocol + '//' + hostnames[hostnames.length - 2] + '.' + hostnames[hostnames.length - 1]
173+
174+
if (hostnames[0] === "pages") {
175+
// subdomain isolation enabled
176+
const hostnames = location.hostname.split('.')
177+
hostnames.shift()
178+
const apiHost = location.protocol + '//' + hostnames.join('.')
179+
} else {
180+
// no subdomain isolation
181+
const apiHost = location.protocol + '//' + location.hostname
182+
}
183+
175184
return fetch(apiHost + '/api/graphql', {
176185
method: 'post',
177186
headers: {
178187
'Accept': 'application/json',
179-
'Authorization': 'Basic ' + authToken,
188+
'Authorization': 'Bearer ' + authToken,
180189
'Content-Type': 'application/json'
181190
},
182191
mode: 'cors',

0 commit comments

Comments
 (0)