Skip to main content

web_vault_from_api_url

Function web_vault_from_api_url 

Source
fn web_vault_from_api_url(api_url: &str) -> String
Expand description

Derive the web-vault base from an API URL when no web-vault/server URL is configured (the bw login --server and cloud paths). Pure so it can be unit-tested without a live client.

  • Single-domain deployment: the API lives at <web-vault>/api (the suffix bw login --server appends), so a trailing /api is stripped to recover the web vault.
  • Split-domain deployment (all Bitwarden cloud regions, and the standard self-host convention): the API is served from an api. host that does not serve the web-vault SPA, so the leading api. host label is rewritten to vault. (https://api.bitwarden.com -> https://vault.bitwarden.com, https://api.bitwarden.eu -> https://vault.bitwarden.eu).
  • Any other shape is treated as its own web vault.

This is a heuristic (see the web_vault_url TODO): a deployment whose API host neither ends in /api nor begins with api. cannot be mapped and will fall through to being used as-is. Such deployments should set bw config server --web-vault <url> for correct links.