From 8cbead170390bc3a1768823ad709b0cc583db3b1 Mon Sep 17 00:00:00 2001 From: Ben Phelps Date: Sat, 27 Aug 2022 02:03:56 +0300 Subject: [PATCH] allow pihole requests to be proxied --- src/components/services/widgets/service/pihole.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/services/widgets/service/pihole.jsx b/src/components/services/widgets/service/pihole.jsx index c477ca332..c29b5d6c1 100644 --- a/src/components/services/widgets/service/pihole.jsx +++ b/src/components/services/widgets/service/pihole.jsx @@ -7,7 +7,13 @@ export default function Pihole({ service }) { const config = service.widget; function buildApiUrl(endpoint) { - const { url } = config; + const { url, proxy } = config; + + if (proxy) { + const fullUrl = `${url}/admin/${endpoint}`; + return "/api/proxy?url=" + encodeURIComponent(fullUrl); + } + return `${url}/admin/${endpoint}`; }