Skip to content

Commit

Permalink
bugfix: window.baseurl is not working in all the cases to fix this us…
Browse files Browse the repository at this point in the history
…ing window.location.pathname (#1041)

* base url is showing as undefined in some cases, fixing that by using pathname

* fixing the pathname

* fix the path
  • Loading branch information
glg-satish-tripathi authored Oct 25, 2023
1 parent 0da77e4 commit 8fd5f1e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ function render () {
const websocketProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
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}`
let pathName = window.location.pathname
if (pathName.startsWith('/')) {
pathName = pathName.substring(1)
}
pathName = pathName.split('/')
const baseUrl = pathName[0]
if (baseUrl !== 'graphiql') {
url = `${window.location.protocol}//${host}//${baseUrl}${window.GRAPHQL_ENDPOINT}`
subscriptionUrl = `${websocketProtocol}//${host}//${baseUrl}${window.GRAPHQL_ENDPOINT}`
} else {
url = `${window.location.protocol}//${host}${window.GRAPHQL_ENDPOINT}`
subscriptionUrl = `${websocketProtocol}//${host}${window.GRAPHQL_ENDPOINT}`
Expand Down

0 comments on commit 8fd5f1e

Please sign in to comment.