From 62f3c7416ec70b06ca62a6ec952f5e1655d57062 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Wed, 18 Feb 2026 01:42:01 -0300 Subject: [PATCH] fix(oauth): use registered redirect_uri for Codex on remote access When accessing OmniRoute remotely (e.g. llms.omniroute.online), the Codex OAuth redirect_uri was incorrectly set to http://localhost:443/callback. OpenAI only accepts the registered http://localhost:1455/auth/callback. This caused 'unknown_error' on auth.openai.com for remote users. Other providers (Google-based: Antigravity, Gemini) are unaffected as Google OAuth accepts any localhost port. --- src/shared/components/OAuthModal.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/shared/components/OAuthModal.tsx b/src/shared/components/OAuthModal.tsx index 36d2839172..c75ec2bf30 100644 --- a/src/shared/components/OAuthModal.tsx +++ b/src/shared/components/OAuthModal.tsx @@ -211,8 +211,15 @@ export default function OAuthModal({ // Authorization code flow // Always use localhost redirect_uri — this is what providers have registered. // On remote, the browser redirects to localhost (error page), user copies URL and pastes back. - const port = window.location.port || (window.location.protocol === "https:" ? "443" : "80"); - const redirectUri = `http://localhost:${port}/callback`; + // Codex (OpenAI) requires exactly http://localhost:1455/auth/callback — the registered URI. + // Other providers (Antigravity/Gemini via Google OAuth) accept any localhost port. + let redirectUri: string; + if (provider === "codex" || provider === "openai") { + redirectUri = "http://localhost:1455/auth/callback"; + } else { + const port = window.location.port || (window.location.protocol === "https:" ? "443" : "80"); + redirectUri = `http://localhost:${port}/callback`; + } const res = await fetch( `/api/oauth/${provider}/authorize?redirect_uri=${encodeURIComponent(redirectUri)}`