Skip to content

Commit

Permalink
handle redirects in host reachability test (#19196)
Browse files Browse the repository at this point in the history
  • Loading branch information
selfcontained authored Dec 5, 2023
1 parent 0e7fae6 commit ca02c26
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/server/src/auth/auth-provider-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,9 @@ export class AuthProviderService {

async isHostReachable(host: string): Promise<boolean> {
try {
const resp = await fetch(`https://${host}`, { timeout: 2000 });
return resp.ok;
// Don't attempt to follow redirects, and manually check response status code
const resp = await fetch(`https://${host}`, { timeout: 2000, redirect: "manual" });
return resp.status <= 399;
} catch (error) {
console.log(`Host is not reachable: ${host}`);
}
Expand Down

0 comments on commit ca02c26

Please sign in to comment.