mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
fix: usage of internal api
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
3076bb4cc3
commit
a2b291294e
4 changed files with 37 additions and 41 deletions
|
@ -39,7 +39,20 @@ export abstract class ApiRequestBuilder<ResponseType> {
|
|||
* @return the base url
|
||||
*/
|
||||
private determineBaseUrl(baseUrl?: string) {
|
||||
return typeof window !== 'undefined' ? baseUrl ?? '/' : baseUrlFromEnvExtractor.extractBaseUrls().internalApiUrl
|
||||
if (this.isSSR()) {
|
||||
const internalApiUrl = baseUrlFromEnvExtractor.extractBaseUrls().internalApiUrl
|
||||
const actualBaseUrl = internalApiUrl ?? baseUrl
|
||||
if (actualBaseUrl === undefined) {
|
||||
throw new Error("Can't make request without forced base url and without internal api url")
|
||||
}
|
||||
return actualBaseUrl
|
||||
} else {
|
||||
return baseUrl ?? '/'
|
||||
}
|
||||
}
|
||||
|
||||
private isSSR() {
|
||||
return typeof window === 'undefined'
|
||||
}
|
||||
|
||||
protected async sendRequestAndVerifyResponse(httpMethod: RequestInit['method']): Promise<ApiResponse<ResponseType>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue