@@ -72,9 +72,14 @@ jellyfinRoute.get('/sessions', async (req: Request, res: Response) => {
7272
7373 console . log ( 'Jellyfin sessions request' ) ;
7474
75+ // Clean the host to remove any protocol prefix
76+ let cleanHost = host ;
77+ cleanHost = cleanHost . replace ( / ^ h t t p s ? : \/ \/ / , '' ) ;
78+ cleanHost = cleanHost . replace ( / \/ + $ / , '' ) ;
79+
7580 const protocol = ssl ? 'https' : 'http' ;
7681 const actualPort = port || '8096' ;
77- const baseUrl = `${ protocol } ://${ host } :${ actualPort } ` ;
82+ const baseUrl = `${ protocol } ://${ cleanHost } :${ actualPort } ` ;
7883 const sessionsUrl = `${ baseUrl } /Sessions` ;
7984
8085 const httpModule = ssl ? https : http ;
@@ -183,9 +188,14 @@ jellyfinRoute.get('/library-stats', async (req: Request, res: Response) => {
183188
184189 console . log ( 'Jellyfin library stats request' ) ;
185190
191+ // Clean the host to remove any protocol prefix
192+ let cleanHost = host ;
193+ cleanHost = cleanHost . replace ( / ^ h t t p s ? : \/ \/ / , '' ) ;
194+ cleanHost = cleanHost . replace ( / \/ + $ / , '' ) ;
195+
186196 const protocol = ssl ? 'https' : 'http' ;
187197 const actualPort = port || '8096' ;
188- const baseUrl = `${ protocol } ://${ host } :${ actualPort } ` ;
198+ const baseUrl = `${ protocol } ://${ cleanHost } :${ actualPort } ` ;
189199
190200 const httpModule = ssl ? https : http ;
191201
0 commit comments