Skip to content

Make the OAuth callback bind host configurable for containerized deployments #147

Description

@den3110

Summary

The OAuth callback listener is hardcoded to loopback, which makes ChatGPT login impossible whenever the browser runs outside the process's network namespace — containers being the common case. Making the bind host configurable is enough to support it.

Detail

src-tauri/src/auth/oauth_server.rs:147:

let server = match Server::http(format!("127.0.0.1:{DEFAULT_PORT}")) {

The redirect target is http://localhost:{port}/auth/callback. When codex-web runs in a container, localhost:1455 in the user's browser is the host's loopback, while the listener sits on the container's — so the callback never lands and complete_login waits forever.

The UI already warns about this ("OAuth login must finish on the same host machine because the callback redirects to localhost"), so the limitation is known — this is a request to lift it rather than a bug report.

Suggested change

Keep loopback as the default and allow opting into a wider bind:

let bind_host = std::env::var("CODEX_SWITCHER_OAUTH_HOST")
    .unwrap_or_else(|_| "127.0.0.1".to_string());

let server = match Server::http(format!("{bind_host}:{DEFAULT_PORT}")) {

The deployment then publishes the callback port on host loopback, e.g. in Docker:

ports:
  - "127.0.0.1:1455:1455"
environment:
  CODEX_SWITCHER_OAUTH_HOST: 0.0.0.0

Verified working: browser -> auth.openai.com -> redirect to localhost:1455 (host) -> Docker forwards -> container listener logs [OAuth] Received callback request, and login completes.

Worth noting the existing random-port fallback (Server::http("127.0.0.1:0")) can't be published ahead of time in a container, so a clear error may be preferable to an unreachable port there.

Version: v0.2.12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions