archivebox.core.routes_utilο
Module Contentsο
Functionsο
Pick a single CSRF_TRUSTED_ORIGINS entry to act as the implicit BASE_URL. |
|
Strip leading |
|
Strip role subdomains and remap loopback hostnames to |
|
Dataο
APIο
- archivebox.core.routes_util._ROLE_SUBDOMAIN_LABELS[source]ο
(βadminβ, βwebβ, βapiβ, βpublicβ)
- archivebox.core.routes_util.derive_base_url_from_csrf(config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
Pick a single CSRF_TRUSTED_ORIGINS entry to act as the implicit BASE_URL.
0.7.3 β 0.9.0 upgrade path: any reverse-proxied 0.7.3 deployment already had
CSRF_TRUSTED_ORIGINS=https://archive.example.comset (required for admin login to work). On upgrade,BASE_URLis the new knob β but it defaults to empty, and falling through toBIND_ADDRproduces an unreachable URL likehttp://0.0.0.0:8000. If the user has exactly one CSRF origin we treat it as the implicit BASE_URL so links/redirects keep pointing at the public hostname they already configured.Returns
""when the inference is ambiguous (multiple origins) or impossible (none set) so callers fall through to their next strategy.
- archivebox.core.routes_util.get_listen_host(config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_listen_parts(config: dict[str, Any] | None = None, **config_kwargs: Any) tuple[str, str | None][source]ο
- archivebox.core.routes_util.strip_role_subdomain(host: str) str[source]ο
Strip leading
admin./web./api./public./snap-*.labels from a host (preserving the port). Strips repeatedly so an already-compounded host likesnap-X.snap-X.<base>reduces all the way down to<base>.Used when we want to recover the canonical base host from a request that arrived on a role subdomain β otherwise builders that prepend their own role label (e.g.
snap-X.) compound onto the existing prefix and you getsnap-X.snap-X.snap-X.<base>on every click.
- archivebox.core.routes_util.canonical_base_host_for_request(request_host: str) str[source]ο
Strip role subdomains and remap loopback hostnames to
archivebox.localhost.Used by the banner suggestion and the in-browser pin endpoint: when the user is hitting the server on raw
localhost:9292or127.0.0.1:9292we want to suggest the wildcard-friendlyarchivebox.localhostfamily instead, so the eventual pinnedBASE_URLplays nicely with subdomain routing without forcing the user to add a /etc/hosts entry.
- archivebox.core.routes_util._root_host_from_listen(config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_base_url(request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_base_host(request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util._build_base_host(subdomain: str | None, request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_admin_host(config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_web_host(config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_api_host(config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_public_host(config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_snapshot_host(snapshot_id: str, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_original_host(domain: str, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_listen_subdomain(request_host: str, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util._scheme_from_request(request=None, config: dict[str, Any] | None = None) str[source]ο
- archivebox.core.routes_util._build_base_url_for_host(host: str, request=None, config: dict[str, Any] | None = None) str[source]ο
- archivebox.core.routes_util.get_admin_base_url(request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_web_base_url(request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_api_base_url(request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_public_base_url(request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_snapshot_base_url(snapshot_id: str, request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.get_original_base_url(domain: str, request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.build_admin_url(path: str = '', request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.build_web_url(path: str = '', request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο
- archivebox.core.routes_util.build_snapshot_url(snapshot_id: str, path: str = '', request=None, config: dict[str, Any] | None = None, **config_kwargs: Any) str[source]ο