Lissy93 / dashy

🚀 A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
https://dashy.to
MIT License
18.05k stars 1.36k forks source link

[BUG] issues with getting pihole stat widgets to work #1681

Closed back-lacking closed 2 months ago

back-lacking commented 2 months ago

Environment

Self-Hosted (Docker)

System

Debian 12, Docker 27.1.1

Version

3.1.1

Describe the problem

So I'm currently trying to setup the widgets for Pihole in Dashy. I added the widgets in my conf file, provided my API key for all the Pihole widgets, and added the Traefik CORS headers from the Dashy documentation to my Pihole's compose file. Looking at Firefox's dev tools, I see that I'm getting a weird network error and errors about missing CORS headers, despite me adding it to my Pihole Compose file and seeing the cors headers middleware in my Traefik dashboard. Relevant configs and screenshots in next section.

Additional info

image the errors in firefox image the network error expanded

      - traefik.http.middlewares.pihole-cors.headers.accesscontrolallowmethods=GET,OPTIONS,PUT
      - traefik.http.middlewares.pihole-cors.headers.accessControlAllowCredentials=true
      - traefik.http.middlewares.pihole-cors.headers.accesscontrolallowheaders=https://home.local.inever.cyou
      - traefik.http.middlewares.pihole-cors.headers.accesscontrolalloworiginlist=https://home.local.inever.cyou
      - traefik.http.middlewares.pihole-cors.headers.accesscontrolmaxage=100
      - traefik.http.middlewares.pihole-cors.headers.addvaryheader=true

the cors headers i added to my piholes compose file. home.local.inever.cyou is the url for the dashy instance.

    widgets:
      - type: pi-hole-stats
        options:
          hostname: https://pihole.local.inever.cyou
          apiKey: apikey
        id: 0_1168_piholestats
      - type: pi-hole-top-queries
        options:
          hostname: https://pihole.local.inever.cyou
          apiKey: apikey
        id: 1_1168_piholetopqueries
      - type: pi-hole-traffic
        options:
          hostname: https://pihole.local.inever.cyou
          apiKey: apikey
        id: 2_1168_piholetraffic

the part of my config file containing the pihole widgets

image the traefik dashboard

Please tick the boxes

back-lacking commented 2 months ago

had a strong feeling that it was. might run it in a vm to see what happens.

back-lacking commented 2 months ago

@youzi-2333 https://tria.ge/240829-d4tgss1hqf/behavioral1 if you wanna see a report from triage. ran this thing in a triage vm

CrazyWolf13 commented 2 months ago

Do not run that file it's a chrome infostealer! It steals your passwords creditcard etc.

back-lacking commented 2 months ago

Yep

CrazyWolf13 commented 2 months ago

Why don't you use the proxy?

https://dashy.to/docs/widgets/#proxying-requests

That normally solves all CORS errors without any middleware or any other setup.

back-lacking commented 2 months ago

@CrazyWolf13 i did try but i dont think it worked. I will try again with one of the widgets again in a bit.

back-lacking commented 2 months ago

@CrazyWolf13 i think the reason why it didnt work previously was that useProxy was previously in the options of the widget instead of outside of the options. i looked at the documentation more carefully and now it works.

back-lacking commented 2 months ago

image yep, applied the useProxy option to all the widgets, and it works.

CrazyWolf13 commented 2 months ago

Awesome! Glad you got it working!