diff --git a/CHANGELOG.md b/CHANGELOG.md index b95426bb..a2f49a60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ * Builtin Prosody: list existing rooms in the settings page * Builtin Prosody: new settings to enable local C2S. For example, can be used with Matterbridge (thanks https://github.com/tytan652) +### Fixes + +* Fix broken API diagnostic. + ## v3.1.0 ### Features diff --git a/server/lib/diagnostic/prosody.ts b/server/lib/diagnostic/prosody.ts index f069eb54..64b0fe70 100644 --- a/server/lib/diagnostic/prosody.ts +++ b/server/lib/diagnostic/prosody.ts @@ -21,12 +21,14 @@ export async function diagProsody (test: string, options: RegisterServerOptions) // FIXME: these tests are very similar to tests in testProsodyCorrectlyRunning. Remove from here? // Testing the prosody config file. let prosodyPort: string + let prosodyHost: string try { const wantedConfig = await getProsodyConfig(options) const filePath = wantedConfig.paths.config result.messages.push(`Prosody will run on port '${wantedConfig.port}'`) prosodyPort = wantedConfig.port + prosodyHost = wantedConfig.host result.messages.push(`Prosody will use ${wantedConfig.baseApiUrl} as base uri from api calls`) @@ -99,7 +101,8 @@ export async function diagProsody (test: string, options: RegisterServerOptions) const testResult = await got(apiUrl, { method: 'GET', headers: { - authorization: 'Bearer ' + await getAPIKey(options) + authorization: 'Bearer ' + await getAPIKey(options), + host: prosodyHost }, responseType: 'json', resolveBodyOnly: true @@ -120,7 +123,8 @@ export async function diagProsody (test: string, options: RegisterServerOptions) const testResult = await got(apiUrl, { method: 'GET', headers: { - authorization: 'Bearer ' + await getAPIKey(options) + authorization: 'Bearer ' + await getAPIKey(options), + host: prosodyHost }, responseType: 'json', resolveBodyOnly: true diff --git a/server/lib/prosody/config.ts b/server/lib/prosody/config.ts index 1c077845..ac7d4819 100644 --- a/server/lib/prosody/config.ts +++ b/server/lib/prosody/config.ts @@ -66,6 +66,7 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise { return new Promise((resolve) => { diff --git a/server/lib/routers/webchat.ts b/server/lib/routers/webchat.ts index 8b67417d..aa23019c 100644 --- a/server/lib/routers/webchat.ts +++ b/server/lib/routers/webchat.ts @@ -13,7 +13,11 @@ const fs = require('fs').promises const proxy = require('express-http-proxy') let httpBindRoute: RequestHandler -let prosodyPort: string | undefined +interface ProsodyHttpBindInfo { + host: string + port: string +} +let currentProsodyHttpBindInfo: ProsodyHttpBindInfo | null = null async function initWebchatRouter (options: RegisterServerOptions): Promise { const { @@ -124,15 +128,16 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise { res.status(404) res.send('Not found') } } else { + logger.info('Changing http-bind port for ' + prosodyHttpBindInfo.port + ', on host ' + prosodyHttpBindInfo.host) const options: ProxyOptions = { https: false, proxyReqPathResolver: async (_req: Request): Promise => { @@ -173,8 +183,8 @@ function changeHttpBindRoute ({ peertubeHelpers }: RegisterServerOptions, port: parseReqBody: true // Note that setting this to false overrides reqAsBuffer and reqBodyEncoding below. // FIXME: should we remove cookies? } - prosodyPort = port - httpBindRoute = proxy('http://localhost:' + port, options) + currentProsodyHttpBindInfo = prosodyHttpBindInfo + httpBindRoute = proxy('http://localhost:' + prosodyHttpBindInfo.port, options) } }