{"record":{"id":"bf5902fd36cbb024","repo":"Hmbown/CodeWhale","slug":"refusing-insecure-base-url-display-base-url","errorCode":null,"errorMessage":"Refusing insecure base URL '{display_base_url}'.\n\nLoopback hosts (localhost, 127.0.0.1, [::1]) are auto-allowed.\nFor other trusted local hosts (LAN, llama.cpp on a private IP, etc.)\nset the env var `{ALLOW_INSECURE_HTTP_ENV}=1` in the shell that runs codewhale and re-run.\n\nExample: `{ALLOW_INSECURE_HTTP_ENV}=1 codewhale` (note the underscores).","messagePattern":"Refusing insecure base URL '(.+?)'\\.\n\nLoopback hosts \\(localhost, 127\\.0\\.0\\.1, \\[::1\\]\\) are auto-allowed\\.\nFor other trusted local hosts \\(LAN, llama\\.cpp on a private IP, etc\\.\\)\nset the env var `(.+?)=1` in the shell that runs codewhale and re-run\\.\n\nExample: `(.+?)=1 codewhale` \\(note the underscores\\)\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/client.rs","lineNumber":681,"sourceCode":"    {\n        return Ok(());\n    }\n\n    if base_url.starts_with(\"http://\")\n        && std::env::var(ALLOW_INSECURE_HTTP_ENV)\n            .or_else(|_| std::env::var(LEGACY_ALLOW_INSECURE_HTTP_ENV))\n            .ok()\n            .as_deref()\n            .is_some_and(|v| v == \"1\" || v.eq_ignore_ascii_case(\"true\"))\n    {\n        logging::warn(format!(\n            \"Using insecure HTTP base URL because {ALLOW_INSECURE_HTTP_ENV} is set\"\n        ));\n        return Ok(());\n    }\n\n    if base_url.starts_with(\"http://\") {\n        anyhow::bail!(\n            \"Refusing insecure base URL '{display_base_url}'.\\n\\\n             \\n\\\n             Loopback hosts (localhost, 127.0.0.1, [::1]) are auto-allowed.\\n\\\n             For other trusted local hosts (LAN, llama.cpp on a private IP, etc.)\\n\\\n             set the env var `{ALLOW_INSECURE_HTTP_ENV}=1` in the shell that runs codewhale and re-run.\\n\\\n             \\n\\\n             Example: `{ALLOW_INSECURE_HTTP_ENV}=1 codewhale` (note the underscores).\",\n        );\n    }\n\n    anyhow::bail!(\n        \"Refusing base URL '{display_base_url}': only HTTPS (or explicitly allowed HTTP) URLs are supported.\",\n    )\n}\n\npub(crate) fn redact_url_for_display(url: &str) -> String {\n    let Ok(mut parsed) = reqwest::Url::parse(url) else {\n        return url.to_string();","sourceCodeStart":663,"sourceCodeEnd":699,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/client.rs#L663-L699","documentation":"The HTTP client guards its base URL: plain http:// is allowed only for loopback hosts (localhost, 127.0.0.1, [::1]) or when CODEWHALE_ALLOW_INSECURE_HTTP=1 (legacy alias DEEPSEEK_ALLOW_INSECURE_HTTP) is set to 1/true in the environment. For any other http:// host this error is returned, with the URL shown redacted. The check exists because an insecure base URL sends your API key and prompts in cleartext.","triggerScenarios":"Constructing the client with base_url = http://192.168.1.20:11434/v1 (LAN ollama/llama.cpp box), http://myserver.local/api, or any non-loopback http URL while neither allow-insecure env var is set.","commonSituations":"Pointing codewhale at a LAN LLM server; using a plain-http reverse proxy on a trusted host; typing http:// instead of https:// for a cloud provider endpoint.","solutions":["Use the https:// URL when the server supports TLS.","For a trusted LAN host, launch with CODEWHALE_ALLOW_INSECURE_HTTP=1 codewhale (export it in the shell that runs codewhale; DEEPSEEK_ALLOW_INSECURE_HTTP also works as a legacy alias).","Tunnel the remote host to loopback (ssh -N -L 8080:host:8080) and use http://127.0.0.1:8080, which is auto-allowed.","Fix scheme typos — most cloud providers are https-only."],"exampleFix":"# before\nexport CODEWHALE_BASE_URL=http://192.168.1.20:11434/v1\ncodewhale   # Refusing insecure base URL\n\n# after (trusted LAN host)\nCODEWHALE_ALLOW_INSECURE_HTTP=1 codewhale\n\n# after (safer: loopback tunnel)\nssh -N -L 11434:192.168.1.20:11434 lanbox &\ncodewhale   # base URL http://127.0.0.1:11434/v1","handlingStrategy":"validation","validationCode":"fn base_url_allowed(url: &str) -> bool {\n    let scheme_ok = url.starts_with(\"https://\")\n        || url.starts_with(\"http://localhost\")\n        || url.starts_with(\"http://127.0.0.1\")\n        || url.starts_with(\"http://[::1]\");\n    scheme_ok || std::env::var(\"CODEWHALE_ALLOW_INSECURE_HTTP\").as_deref() == Ok(\"1\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default provider configs to https:// URLs.","Reserve CODEWHALE_ALLOW_INSECURE_HTTP for trusted LAN hosts — it downgrades all transport security for the session.","Lint configuration files for non-loopback http:// URLs in CI."],"tags":["rust","security","http","base-url","environment-variable"],"backgroundTag":"insecure-http-blocked","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}