Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Make sure redirect URI is HTTPS unless it is for localhost (#9076)

chuckbutkus7dede37fd80f
diff --git a/frontend/src/utils/generate-auth-url.ts b/frontend/src/utils/generate-auth-url.ts
index 8201d0b3f7..9e8d9a267b 100644
--- a/frontend/src/utils/generate-auth-url.ts
+++ b/frontend/src/utils/generate-auth-url.ts
@@ -5,7 +5,10 @@
* @returns The URL to redirect to for OAuth
*/
export const generateAuthUrl = (identityProvider: string, requestUrl: URL) => {
- const redirectUri = `${requestUrl.origin}/oauth/keycloak/callback`;
+ // Use HTTPS protocol unless the host is localhost
+ const protocol =
+ requestUrl.hostname === "localhost" ? requestUrl.protocol : "https:";
+ const redirectUri = `${protocol}//${requestUrl.host}/oauth/keycloak/callback`;
let authUrl = requestUrl.hostname
.replace(/(^|\.)staging\.all-hands\.dev$/, "$1auth.staging.all-hands.dev")
.replace(/(^|\.)app\.all-hands\.dev$/, "auth.app.all-hands.dev")