Preserve Cloudfare HTTP cookies in codex (#17783)

## Summary
- Adds a process-local, in-memory cookie store for ChatGPT HTTP clients.
- Limits cookie storage and replay to a shared ChatGPT host allowlist.
- Wires the shared store into the default Codex reqwest client and
backend client.
- Shares the ChatGPT host allowlist with remote-control URL validation
to avoid drift.
- Enables reqwest cookie support and updates lockfiles.
This commit is contained in:
Shijie Rao authored and GitHub committed 2026-04-21 14:40:15 -07:00
1 parent be75785504
commit c5e9c6f71f
9 files changed
+387 -5

No files matched your search

+11 -1
View File
@@ -8,6 +8,7 @@ use codex_client::BuildCustomCaTransportError;
use codex_client::CodexHttpClient;
pub use codex_client::CodexRequestBuilder;
use codex_client::build_reqwest_client_with_custom_ca;
use codex_client::with_chatgpt_cloudflare_cookie_store;
use codex_terminal_detection::user_agent;
use reqwest::header::HeaderMap;
use reqwest::header::HeaderValue;
@@ -201,7 +202,15 @@ pub fn create_client() -> CodexHttpClient {
pub fn build_reqwest_client() -> reqwest::Client {
try_build_reqwest_client().unwrap_or_else(|error| {
tracing::warn!(error = %error, "failed to build default reqwest client");
reqwest::Client::new()
with_chatgpt_cloudflare_cookie_store(reqwest::Client::builder())
.build()
.unwrap_or_else(|fallback_error| {
tracing::warn!(
error = %fallback_error,
"failed to build fallback reqwest client with ChatGPT Cloudflare cookie store"
);
reqwest::Client::new()
})
})
}
@@ -219,6 +228,7 @@ pub fn try_build_reqwest_client() -> Result<reqwest::Client, BuildCustomCaTransp
if is_sandboxed() {
builder = builder.no_proxy();
}
builder = with_chatgpt_cloudflare_cookie_store(builder);
build_reqwest_client_with_custom_ca(builder)
}