Why a configured base URL cannot be used, or undefined. Checked in this
order (the first problem is reported):
it must parse as an absolute URL;
the scheme must be http(s). The default transport also gates the scheme per
hop, but the engine is exported as a library and may be handed a custom
transport that does no such check;
no query or fragment: request paths are appended to the base URL as a
string, so http://h/?x=1 would request /?x=1/api/v1/... and http://h/#f
would request /;
no backslash: WHATWG ends an http(s) host at one, as at a /, while text-based code
reads on, so https://u:pw@a.example\@b.example could be checked as one host and its
credentials sent to another;
a % in the user name or password must start a valid escape (%25 for a
literal one): the userinfo is decoded for the Authorization header;
no surrounding whitespace and no whitespace or control character inside:
new URL() trims the first and drops tab/CR/LF inside silently, so the URL
requested would not be the one typed;
the scheme followed by exactly // and the host (not http:host, http:/host or
http:///host): WHATWG skips any slashes after an http(s) scheme and repairs the URL
silently, so the host requested would not be the one typed either;
the path must not end in /api/v1, which the client appends itself
(/api/v1/api/v1/... is a 404).
The reason never echoes the value, nor a part of it: a base URL may carry a password. A
scheme is named (Unsupported scheme "ftp:") only when the value spells one
(<scheme>://), since a scheme-less user:password@host parses with the user name as its
scheme.
Why a configured base URL cannot be used, or
undefined. Checked in this order (the first problem is reported):http://h/?x=1would request/?x=1/api/v1/...andhttp://h/#fwould request/;/, while text-based code reads on, sohttps://u:pw@a.example\@b.examplecould be checked as one host and its credentials sent to another;%in the user name or password must start a valid escape (%25for a literal one): the userinfo is decoded for the Authorization header;new URL()trims the first and drops tab/CR/LF inside silently, so the URL requested would not be the one typed;//and the host (nothttp:host,http:/hostorhttp:///host): WHATWG skips any slashes after an http(s) scheme and repairs the URL silently, so the host requested would not be the one typed either;/api/v1, which the client appends itself (/api/v1/api/v1/...is a 404).The reason never echoes the value, nor a part of it: a base URL may carry a password. A scheme is named (
Unsupported scheme "ftp:") only when the value spells one (<scheme>://), since a scheme-lessuser:password@hostparses with the user name as its scheme.