Skip to content

Commit

Permalink
Fix application start when YDOC_SERVER_URL is undefined (#11160)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frizi authored Sep 24, 2024
1 parent e6c0385 commit e2cf20a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/gui2/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="vite/client" />

declare const PROJECT_MANAGER_URL: string
declare const YDOC_SERVER_URL: string
declare const PROJECT_MANAGER_URL: string | undefined
declare const YDOC_SERVER_URL: string | undefined
declare const IS_CLOUD_BUILD: boolean

interface Document {
Expand Down
8 changes: 5 additions & 3 deletions app/gui2/src/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ function main() {
localStorage.setItem(INITIAL_URL_KEY, location.href)
}

const resolveEnvUrl = (url: string) => url.replace('__HOSTNAME__', window.location.hostname)
const resolveEnvUrl = (url: string | undefined) =>
url?.replace('__HOSTNAME__', window.location.hostname)

const config = configValue(mergeConfig(baseConfig, urlParams()))
const supportsVibrancy = config.window.vibrancy
const shouldUseAuthentication = config.authentication.enabled
const projectManagerUrl = config.engine.projectManagerUrl || resolveEnvUrl(PROJECT_MANAGER_URL)
const ydocUrl = config.engine.ydocUrl || resolveEnvUrl(YDOC_SERVER_URL)
const projectManagerUrl =
(config.engine.projectManagerUrl || resolveEnvUrl(PROJECT_MANAGER_URL)) ?? null
const ydocUrl = (config.engine.ydocUrl || resolveEnvUrl(YDOC_SERVER_URL)) ?? null
const initialProjectName = config.startup.project || null
const urlWithoutStartupProject = new URL(location.toString())
urlWithoutStartupProject.searchParams.delete('startup.project')
Expand Down

0 comments on commit e2cf20a

Please sign in to comment.