backend-common: use readHttpServerOptions to read SingleHostDiscovery options

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: blam <ben@blam.sh>
Co-authored-by: Johan Haals <johan.haals@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-01-09 16:04:57 +01:00
parent c44dc6225f
commit 011c8a8ff1
@@ -16,8 +16,7 @@
import { Config } from '@backstage/config';
import { PluginEndpointDiscovery } from './types';
import { readBaseOptions } from '../service/lib/config';
import { DEFAULT_PORT } from '../service/lib/ServiceBuilderImpl';
import { readHttpServerOptions } from '@backstage/backend-app-api';
/**
* SingleHostDiscovery is a basic PluginEndpointDiscovery implementation
@@ -43,9 +42,9 @@ export class SingleHostDiscovery implements PluginEndpointDiscovery {
const basePath = options?.basePath ?? '/api';
const externalBaseUrl = config.getString('backend.baseUrl');
const { listenHost = '::', listenPort = DEFAULT_PORT } = readBaseOptions(
config.getConfig('backend'),
);
const {
listen: { host: listenHost = '::', port: listenPort },
} = readHttpServerOptions(config.getConfig('backend'));
const protocol = config.has('backend.https') ? 'https' : 'http';
// Translate bind-all to localhost, and support IPv6