Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fixes for keycloak in localhost (#7079)

tofarrc51f07bd1f0e
diff --git a/frontend/src/utils/generate-github-auth-url.ts b/frontend/src/utils/generate-github-auth-url.ts
index 082376ccbd..c2e0189240 100644
--- a/frontend/src/utils/generate-github-auth-url.ts
+++ b/frontend/src/utils/generate-github-auth-url.ts
@@ -6,12 +6,10 @@
*/
export const generateGitHubAuthUrl = (clientId: string, requestUrl: URL) => {
const redirectUri = `${requestUrl.origin}/oauth/keycloak/callback`;
- const baseUrl = `${requestUrl.origin}`
- .replace("https://", "")
- .replace("http://", "");
- const authUrl = baseUrl
+ const authUrl = requestUrl.hostname
.replace(/(^|\.)staging\.all-hands\.dev$/, "$1auth.staging.all-hands.dev")
- .replace(/(^|\.)app\.all-hands\.dev$/, "auth.app.all-hands.dev");
+ .replace(/(^|\.)app\.all-hands\.dev$/, "auth.app.all-hands.dev")
+ .replace(/(^|\.)localhost$/, "auth.staging.all-hands.dev");
const scope = "openid email profile";
return `https://${authUrl}/realms/allhands/protocol/openid-connect/auth?client_id=github&response_type=code&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scope)}`;
};