From ca02c26021432ecc5ef51c4972d1d0861a189567 Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Tue, 5 Dec 2023 11:45:12 -0700 Subject: [PATCH] handle redirects in host reachability test (#19196) --- components/server/src/auth/auth-provider-service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/server/src/auth/auth-provider-service.ts b/components/server/src/auth/auth-provider-service.ts index 56fcdf2936fabe..851308766d5a28 100644 --- a/components/server/src/auth/auth-provider-service.ts +++ b/components/server/src/auth/auth-provider-service.ts @@ -415,8 +415,9 @@ export class AuthProviderService { async isHostReachable(host: string): Promise { 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}`); }