Skip to content

Commit

Permalink
fix: if the backend url contains a path and no slash at the end, the …
Browse files Browse the repository at this point in the history
…backend responses with a 302 redirect, which is not possible in XHR request
  • Loading branch information
m-benamor committed Sep 28, 2023
1 parent 6f7a19e commit 820192f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export class AppConfigService {
}

private validateBackendUrl(config: PatientList) {
return this.httpClient.get<string>(config.url.toString())
// if the url contains a path and no slash at the end, the backend responses with a 302 redirect, which is not possible in XHR request
let urlSuffix = new URL("http://blala.com/mainzelliste/").pathname.endsWith('/') ?"":"/";
return this.httpClient.get<string>(config.url.toString() + urlSuffix)
.pipe(map(_r => 'Mainzelliste is online'),
catchError(_e => throwError(new Error("Mainzelliste backend is offline")))
)
Expand Down

0 comments on commit 820192f

Please sign in to comment.