@@ -10,7 +10,7 @@ const sanitize = require('sanitize-filename')
1010const contentDisposition = require ( 'content-disposition' )
1111const { WebSocketServer } = require ( 'ws' )
1212const { runconvert } = require ( './convert/convert' )
13- const { wer } = require ( './utils' )
13+ const { wer, readBaseUrls } = require ( './utils' )
1414const debug = require ( 'debug' ) ( 'botium-speech-processing-routes' )
1515
1616const cachePathStt = ( process . env . BOTIUM_SPEECH_CACHE_DIR && path . join ( process . env . BOTIUM_SPEECH_CACHE_DIR , 'stt' ) ) || './resources/.cache/stt'
@@ -714,14 +714,11 @@ const wssStreams = {}
714714 stream . events . on ( 'close' , ( ) => delete wssStreams [ streamId ] )
715715 wssStreams [ streamId ] = stream
716716
717- const proxyHost = req . headers [ 'x-forwarded-host' ]
718- const host = proxyHost || req . get ( 'host' )
719-
720- const wsProtocol = ( req . protocol === 'https' ? 'wss' : 'ws' )
717+ const baseUrls = readBaseUrls ( req )
721718 res . json ( {
722- wsUri : `${ wsProtocol } :// ${ host } /${ streamId } ` ,
723- statusUri : `${ req . protocol } :// ${ host } /api/sttstatus/${ streamId } ` ,
724- endUri : `${ req . protocol } :// ${ host } /api/sttend/${ streamId } `
719+ wsUri : `${ baseUrls . wsUri } /${ streamId } ` ,
720+ statusUri : `${ baseUrls . baseUri } /api/sttstatus/${ streamId } ` ,
721+ endUri : `${ baseUrls . baseUri } /api/sttend/${ streamId } `
725722 } ) . end ( )
726723 } catch ( err ) {
727724 return next ( err )
0 commit comments