Skip to main content

HostDiscovery

Home > @backstage/backend-app-api > HostDiscovery

HostDiscovery is a basic PluginEndpointDiscovery implementation that can handle plugins that are hosted in a single or multiple deployments.

The deployment may be scaled horizontally, as long as the external URL is the same for all instances. However, internal URLs will always be resolved to the same host, so there won't be any balancing of internal traffic.

Signature:

class HostDiscovery implements DiscoveryService 

Implements: DiscoveryService

Methods

MethodModifiersDescription
fromConfig(config, options)static

Creates a new HostDiscovery discovery instance by reading from the backend config section, specifically the .baseUrl for discovering the external URL, and the .listen and .https config for the internal one.

Can be overridden in config by providing a target and corresponding plugins in discovery.endpoints. eg.

discovery:
endpoints:
- target: https://internal.example.com/internal-catalog
plugins: [catalog]
- target: https://internal.example.com/secure/api/{{pluginId}}
plugins: [auth, permission]
- target:
internal: https://internal.example.com/search
external: https://example.com/search
plugins: [search]

The basePath defaults to /api, meaning the default full internal path for the catalog plugin will be http://localhost:7007/api/catalog.

| | [getBaseUrl(pluginId)](/docs/reference/backend-app-api.hostdiscovery.getbaseurl) | | | | [getExternalBaseUrl(pluginId)](/docs/reference/backend-app-api.hostdiscovery.getexternalbaseurl) | | |