Skip to content

Commit

Permalink
make url dynamic so even if the graphiql is deployed on baseUrl it ca…
Browse files Browse the repository at this point in the history
…n work (#1037)
  • Loading branch information
glg-satish-tripathi authored Oct 23, 2023
1 parent 3c40d45 commit 54bc3ec
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,16 @@ function fetcherWrapper (fetcher, cbs = []) {

function render () {
const host = window.location.host

const websocketProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'

const url = `${window.location.protocol}//${host}${window.GRAPHQL_ENDPOINT}`
const subscriptionUrl = `${websocketProtocol}//${host}${window.GRAPHQL_ENDPOINT}`
let url = ''
let subscriptionUrl = ''
if (window.baseurl) {
url = `${window.location.protocol}//${host}${window.baseurl}${window.GRAPHQL_ENDPOINT}`
subscriptionUrl = `${websocketProtocol}//${host}${window.baseurl}${window.GRAPHQL_ENDPOINT}`
} else {
url = `${window.location.protocol}//${host}${window.GRAPHQL_ENDPOINT}`
subscriptionUrl = `${websocketProtocol}//${host}${window.GRAPHQL_ENDPOINT}`
}

const availablePlugins = window.GRAPHIQL_PLUGIN_LIST
.map(plugin => window[`GRAPIHQL_PLUGIN_${plugin.toUpperCase()}`])
Expand Down

0 comments on commit 54bc3ec

Please sign in to comment.