From d6588a694cbdd997b11651480c580c379761d912 Mon Sep 17 00:00:00 2001 From: Thorben Grove Date: Tue, 5 Dec 2023 08:14:24 +0100 Subject: [PATCH] let the user choose wether to use http or https --- docs/widgets/services/fritzbox.md | 4 ++-- src/widgets/fritzbox/proxy.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/widgets/services/fritzbox.md b/docs/widgets/services/fritzbox.md index de63d77f..50f3697a 100644 --- a/docs/widgets/services/fritzbox.md +++ b/docs/widgets/services/fritzbox.md @@ -11,12 +11,12 @@ Home Network > Network > Network Settings > Access Settings in the Home Network [x] Transmit status information over UPnP ``` -You don't need to provide any credentials. +You don't need to provide any credentials. Since that, you should consider using `http` instead of `https` as the requests are significantly faster. Allowed fields (limited to a max of 4): `["connectionStatus", "upTime", "maxDown", "maxUp", "down", "up", "received", "sent", "externalIPAddress"]`. ```yaml widget: type: fritzbox - url: https://192.168.178.1 + url: http://192.168.178.1 ``` diff --git a/src/widgets/fritzbox/proxy.js b/src/widgets/fritzbox/proxy.js index b9c35eed..353231d2 100644 --- a/src/widgets/fritzbox/proxy.js +++ b/src/widgets/fritzbox/proxy.js @@ -60,7 +60,8 @@ export default async function fritzboxProxyHandler(req, res) { } const serviceWidgetUrl = new URL(serviceWidget.url); - const apiBaseUrl = `http://${serviceWidgetUrl.hostname}:49000`; + const port = serviceWidgetUrl.protocol === "https:" ? 49443 : 49000; + const apiBaseUrl = `${serviceWidgetUrl.protocol}//${serviceWidgetUrl.hostname}:${port}`; if (!serviceWidget.fields?.length > 0) { serviceWidget.fields = fritzboxDefaultFields;