glanceapp / glance

A self-hosted dashboard that puts all your feeds in one place
GNU Affero General Public License v3.0
8.56k stars 297 forks source link

[Bug] Pi-hole API Response Contains Invalid JSON #209

Closed Szymok closed 2 months ago

Szymok commented 2 months ago

Pi-hole API Response Contains Invalid JSON

When fetching DNS stats at Glance from the Pi-hole API at https://url/api.php?summaryRaw&topItems&overTimeData10mins&auth=token, the response contains invalid JSON with the error "invalid character '<' looking for beginning of value".

image

Expected Behavior

The Glance should return a valid graph response with the requested DNS statistics.

Actual Behavior

The API returns an HTML response instead of JSON, causing the error "invalid character '<' looking for beginning of value" when parsing the response.

Steps to Reproduce

  1. Set the Pi-hole API URL and token in the Glance application configuration:
    - type: dns-stats
    service: pihole
    url: https://pihole.domain.eu/
    token: YOUR_TOKEN
  2. Run the Glance application to fetch the DNS stats.

Environment

Additional Information

Please let me know if you need any other information to investigate this issue.

svilenmarkov commented 2 months ago

Thanks for reporting this!

I can't seem to replicate the issue on my end while using the same version of Pi-hole. Do you have a way of checking the full HTML response? I'm wondering if it's a 404 or something else.

This might have something to do with the lack or addition of /admin/ in the path. For me, this URL works:

https://url/admin/api.php?...

And this does not:

https://url/api.php?...

You should only specify the domain in the config, as I believe you already have.

Szymok commented 2 months ago

OK, nvm, i found that i had in traefik configured middlewares to replace the admin and prefix to get a shorter URL. Everything works like a charm, thank you and sorry for bothering! :D

svilenmarkov commented 2 months ago

No problem, glad you got it sorted out. 😄