revenz / Fenrus

A personal home page for quick access to all your personal apps/sites.
MIT License
518 stars 31 forks source link

Pi-Hole SmartApp API Issues #149

Closed EmilSepa closed 1 year ago

EmilSepa commented 1 year ago

Hey :) First of all, thank you for your great work 👍 I have an issue with the API Call for the SmartApp Pi-Hole.

Every time I try to set the API data, I get an error.

In the logs of Fenrus I saw that Fenrus adds /admin/api.php to the API URL .

However, I believe that this is no longer supported in this form. If you are already logged in to PiHole in another browser tab, you can still call the API this way, but for a call without login another solution is used now (correct me if I'm wrong)

If I'm right, the API is now called like this: /admin/api.php/?summary&auth=APITOKEN .

Therefore I have adapted the call in the file code.js under /app/apps/Smart/Pi-Hole accordingly.

If I now try the call via Fenrus again, an error still appears. Maybe it is because of the different JSON formatting? (see picture 1 and picture 2)

Picture 1 (API Call per /summary/&auth=APITOKEN)

grafik

Picture 2 (API call per /api.php, but with login before on another browser tab)

grafik

When I test it, "test result false" appears in the logs .

After saving then later in the logs appears:

13:56:23.146error in app: Pi-hole TypeError: percent.toFixed is not a function

`at PiHole.status (/app/apps/Smart/Pi-hole/code.js:23:33)

at processTicksAndRejections (node:internal/process/task_queues:96:5)

at async AppRouter.getStatus (/app/routes/AppRouter.js:154:26)

at async AppRouter.safeAsync (/app/routes/FenrusRouter.js:28:13)

at async /app/routes/AppRouter.js:37:69` 
cvondra commented 1 year ago

Same issue.

damda58 commented 1 year ago

The pi-hole api has changed and now requires an apikey.

cvondra commented 1 year ago

I have used the entire url with the new request and included the api key and still no love from within Fenrus. I get replies without issue using the url in the browser.

EmilSepa commented 1 year ago

The pi-hole api has changed and now requires an apikey.

Hey @damda58 :), yeah i know, that is what i meant with "APITOKEN". I also tried @cvondra approach, before i opend the issue.

revenz commented 1 year ago

Fixed in the next version (dotnet rewrite)