Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/shared/components/OAuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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") {

Copilot AI Feb 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks for provider === "openai", but "openai" is not a registered provider in the PROVIDERS map (src/lib/oauth/providers/index.ts) or in the provider constants (src/shared/constants/providers.ts). Only "codex" exists as an OAuth provider. This check is unreachable dead code and should be removed. The condition should simply be if (provider === "codex").

Suggested change
if (provider === "codex" || provider === "openai") {
if (provider === "codex") {

Copilot uses AI. Check for mistakes.
redirectUri = "http://localhost:1455/auth/callback";
} else {
const port = window.location.port || (window.location.protocol === "https:" ? "443" : "80");
redirectUri = `http://localhost:${port}/callback`;
}
Comment on lines +217 to +222

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and future maintainability, it's better to use an array with includes() for checking the provider. This approach is more scalable if you need to add more providers that require this specific redirect URI in the future. I'd also recommend extracting the hardcoded redirect URI into a constant defined at a suitable scope.

Suggested change
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`;
}
if (["codex", "openai"].includes(provider)) {
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)}`
Expand Down
Loading