#374 - private setting to change the HTTP host

This commit is contained in:
Simon Cambier
2024-05-25 23:01:43 +02:00
parent 6566a2e958
commit efdfbbcf8a
2 changed files with 9 additions and 2 deletions

View File

@@ -67,6 +67,8 @@ export interface OmnisearchSettings extends WeightingSettings {
httpApiEnabled: boolean httpApiEnabled: boolean
httpApiPort: string httpApiPort: string
httpApiNotice: boolean httpApiNotice: boolean
DANGER_httpHost: string | null
} }
/** /**
@@ -751,6 +753,8 @@ export function getDefaultSettings(app: App): OmnisearchSettings {
welcomeMessage: '', welcomeMessage: '',
verboseLogging: false, verboseLogging: false,
DANGER_httpHost: null,
} }
} }

View File

@@ -44,11 +44,14 @@ export function getServer(plugin: OmnisearchPlugin) {
server.listen( server.listen(
{ {
port: parseInt(port), port: parseInt(port),
host: 'localhost', host: plugin.settings.DANGER_httpHost ?? 'localhost',
}, },
() => { () => {
console.log(`Omnisearch - Started HTTP server on port ${port}`) console.log(`Omnisearch - Started HTTP server on port ${port}`)
if (plugin.settings.httpApiNotice) { if (plugin.settings.DANGER_httpHost && plugin.settings.DANGER_httpHost !== 'localhost') {
new Notice(`Omnisearch - Started non-localhost HTTP server at ${plugin.settings.DANGER_httpHost}:${port}`, 120_000)
}
else if (plugin.settings.httpApiNotice) {
new Notice(`Omnisearch - Started HTTP server on port ${port}`) new Notice(`Omnisearch - Started HTTP server on port ${port}`)
} }
} }