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.2k stars 1.37k forks source link

[QUESTION] What am I missing/doing wrong in the Pi Hole Stats widget? #391

Closed KierenConnell closed 2 years ago

KierenConnell commented 2 years ago

Question

Configured the Pi Hole stats widget as per the example, but it returns Unable to fetch data

name: Pi-Hole Stats
icon: hl-pihole
displayData:
  sortBy: default
  rows: 1
  cols: 1
  collapsed: false
  hideForGuests: false
widgets:
  - type: pi-hole-stats
    options:
      hostname: 'https://pihole-1.kierenconnell.com/admin/api.php'

Have tried setting hostname as direct IP to Pi Hole as per example, and also api.php

Category

Widgets

Please tick the boxes

liss-bot commented 2 years ago

Welcome to Dashy 👋 It's great to have you here, but unfortunately your ticket has been closed to prevent spam. Before reopening this issue, please ensure the following criteria are met.

Issues are sometimes closed when users:

Before you reopen this issue, please also ensure that:

Once you have verified the above standards are met, you may reopen this issue. Sorry for any inconvenience caused, I'm just a bot, and sometimes make mistakes 🤖

Lissy93 commented 2 years ago

@EVOTk also raised this too. It seems to be a CORS error, I'll implement an option to proxy the request with the correct headers.

In the meantime, verify that you've got API access enabled on your Pi-Hole, can you access https://location-of-pi-hole.local/admin/api.php. If you were to set the CORS headers to allow requests from Dashy, this would also fix your issue.

Lissy93 commented 2 years ago

Actually, just noticed in your config sipped that you've got a mistake, the hostname should just be: https://pihole-1.kierenconnell.com. Could you also share the output of the console, so that I can debug the issue, is there an error in Red?

KierenConnell commented 2 years ago

Same error Unable to fetch data if I have hostname as https://pihole-1.kierenconnell.com image

Lissy93 commented 2 years ago

Yup, that's a missing CORS header. Depending on how you're hosting Pi-Hole you should just be able to add:

Access-Control-Allow-Origin: https://location-of-dashy/

But I will also add a proxy server which you can then use as an option

Lissy93 commented 2 years ago

Heya @KierenConnell I've pushed a fix out for this, you can now proxy requests to Pi-Hole, without the need to apply any headers on Pi-Hole's side :) Hope that helps, and happy new year 🎇

KierenConnell commented 2 years ago

Awesome! Working perfectly now Thanks!

liss-bot commented 2 years ago

The fix for this issue has now been released in Dashy 2.0.0 ✨

If you haven't done so already, please update your instance to 2.0.0 or later. See Dashy 2.0.0 for full info.

Feel free to reach out if you need any more support. If you are enjoying Dashy, consider supporting the project.