Skip to content

Commit

Permalink
turn apiHost into an immutable function
Browse files Browse the repository at this point in the history
  • Loading branch information
tcbyrd committed May 12, 2018
1 parent a98ff35 commit f90f446
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions graphql/enterprise/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ <h3>Create a <a href="https://help.github.com/articles/creating-a-personal-acces

const hostnames = location.hostname.split('.')

if (hostnames[0] === "pages") {
// subdomain isolation enabled, so remove the first part of the URL
hostnames.shift()
const apiHost = location.protocol + '//' + hostnames.join('.')
} else {
// no subdomain isolation
const apiHost = location.protocol + '//' + location.hostname
}
const apiHost = function () {
if (hostnames[0] === "pages") {
// subdomain isolation enabled, so remove the first part of the URL
hostnames.shift()
return location.protocol + '//' + hostnames.join('.')
} else {
// no subdomain isolation
return location.protocol + '//' + location.hostname
}
}()

return fetch(apiHost + '/api/graphql', {
method: 'post',
Expand Down

0 comments on commit f90f446

Please sign in to comment.