BigPizzaV3/CodexPlusPlus · error · Error
请输入完整的 HTTPS API 地址
Error message
请输入完整的 HTTPS API 地址
What it means
apiEndpoint() validates the user-supplied base URL by constructing a URL object; if String(raw).trim() is empty, relative, or otherwise unparseable by the WHATWG URL parser, it throws this error. It is the first line of validation for external (OpenAI-compatible) channel configuration and happens before any network request.
Solutions
- Enter a full absolute URL including scheme, e.g. https://api.openai.com/v1
- Check for typos in 'https://' (e.g. missing colon or slashes)
- Trim surrounding whitespace/newlines from the pasted URL before saving
- If a proxy has no public absolute URL, host it under a resolvable https:// address
Example fix
// before
apiEndpoint('api.example.com/v1')
// after
apiEndpoint('https://api.example.com/v1') Defensive patterns
Strategy: validation
Validate before calling
function validAbsoluteHttpsUrl(raw) { try { const u = new URL(String(raw).trim()); return u.protocol === 'https:' && !u.username && !u.password && !u.search && !u.hash; } catch { return false; } }
if (!validAbsoluteHttpsUrl(input)) alert('Enter a full https:// URL'); Try / catch
let endpoint;
try { endpoint = apiEndpoint(raw); } catch (e) { showError('API 地址无效:请输入完整 HTTPS 地址'); return; } Prevention
- Always paste URLs starting with https://
- Trim whitespace before validation
- Validate the URL in the form's input handler, before submit
- Show a live preview of the normalized endpoint so users see what will be called
When it happens
Trigger: apiEndpoint called with '' (empty field), 'localhost:8080' without scheme, 'my-api.example.com/v1', 'http//typo', or any string new URL() cannot parse as an absolute URL.
Common situations: User leaves the API base URL field blank in the settings form; user types a bare hostname without https://; copy-paste drops the scheme; user pastes a path like /v1/chat/completions alone.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/ba9751830c86ac85.
Report an issue: GitHub.
Appendix: source
Thrown at tools/conversation-canvas/external-api.mjs:3
// OpenAI-compatible Chat Completions. Never persist credentials in tree checkpoints.
export function apiEndpoint(raw){
let url;try{url=new URL(String(raw).trim());}catch{throw Error('请输入完整的 HTTPS API 地址');}
if(url.protocol!=='https:'||url.username||url.password||url.search||url.hash)throw Error('API 地址须使用 HTTPS,且不含账号、密码、查询参数或片段');
const path=url.pathname.replace(/\/+$/,'');
url.pathname=path.endsWith('/chat/completions')?path:(path||'/v1')+'/chat/completions';
return url.href;
}
export function apiConfig(input){
const channel=input?.channel==='external'?'external':'native';
const value={channel,baseUrl:String(input?.baseUrl||'').trim(),model:String(input?.model||'').trim(),key:String(input?.key||'').trim(),remember:input?.remember===true,speed:input?.speed==='provider'?'provider':'fast',revision:input?.revision||crypto.randomUUID()};
if(channel==='external'){
value.endpoint=apiEndpoint(value.baseUrl);
if(!value.model||value.model.length>200)throw Error('请填写 API 的模型名称');
if(!value.key||/[\r\n]/.test(value.key))throw Error('请在设置中填写有效 API Key');
}
return value;
}
export function storedApiConfig(config){View on GitHub (pinned to b1ed92e5e4)