mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-30 14:55:27 -04:00
Add basic realtime communication (#2118)
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
3b86afc17c
commit
0da51bba67
23 changed files with 624 additions and 53 deletions
|
@ -6,8 +6,25 @@
|
|||
|
||||
import { isMockMode } from './test-modes'
|
||||
|
||||
if (!isMockMode && process.env.NEXT_PUBLIC_BACKEND_BASE_URL === undefined) {
|
||||
throw new Error('NEXT_PUBLIC_BACKEND_BASE_URL is unset and mock mode is disabled')
|
||||
/**
|
||||
* Generates the backend URL from the environment variable `NEXT_PUBLIC_BACKEND_BASE_URL` or the mock default if mock mode is activated.
|
||||
*
|
||||
* @throws Error if the environment variable is unset or doesn't end with "/"
|
||||
* @return the backend url that should be used in the app
|
||||
*/
|
||||
const generateBackendUrl = (): string => {
|
||||
if (!isMockMode) {
|
||||
const backendUrl = process.env.NEXT_PUBLIC_BACKEND_BASE_URL
|
||||
if (backendUrl === undefined) {
|
||||
throw new Error('NEXT_PUBLIC_BACKEND_BASE_URL is unset and mock mode is disabled')
|
||||
} else if (!backendUrl.endsWith('/')) {
|
||||
throw new Error("NEXT_PUBLIC_BACKEND_BASE_URL must end with an '/'")
|
||||
} else {
|
||||
return backendUrl
|
||||
}
|
||||
} else {
|
||||
return '/'
|
||||
}
|
||||
}
|
||||
|
||||
export const backendUrl = isMockMode ? '/' : (process.env.NEXT_PUBLIC_BACKEND_BASE_URL as string)
|
||||
export const backendUrl = generateBackendUrl()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue