Closed AlexFullmoon closed 2 years ago
If it helps you any, I just looked at my own, and it seems to be working fine, and from looking through the API JSON results, the format and data points haven't changed in a long time so in theory should still be parsing fine by default.
Ugh. As I suspect, its again something something CORS something misconfiguration headers.
Any advice on how to debug that?
CORS issues are my bane as well debugging and I am afraid my knowledge on working around them is limited. I wonder though, are you using a reverse proxy internally for your hostnames? if so it may perhaps work better if you call the PiHole by it's IP address directly.
I wonder though, are you using a reverse proxy internally for your hostnames?
Sure I do, nginx (with wather limited configuration options). Calling through http://IP would cause mixed content error.
I could easily have my web tools mixed up, but im pretty sure you can call http://IP:port i think, if that helps.
Likely related to this PR cc @bastienwirtz we should finalize on a fetch
mixin pattern and get it merged
For anyone needing to diagnose this CORS issue, this thread may solve part of the problem temporarily: https://discourse.pi-hole.net/t/add-domain-to-authorized-hostnames-permanently/32007/2.
To summarise, you can modify, the $AUTHORISED_HOSTNAMES
declaration in the auth.php
file of pihole found at /path-to-pihole/admin/scripts/pi-hole/php/auth.php
to include the domain or IP of your homer instance. Do note this will likely need updating every time you update Pi-hole. Additionally because of the use of credentials when fetching data, you will also need to set the Access-Control-Allow-Credentials
to true, this header should be set on your proxy.
As for the SyntaxError you will see, after some poking, it is the beginning of an error from Pi-hole that reads: "Failed CORS: [browser_origin] vs [authorised_hostnames]", this is likely caused by CORS headers being set on your proxy instead of on your Pi-hole instance itself. Changing it to be on Pi-hole fixed this problem for me.
Edit: Fixed Typos
Pihole at https://dns.mydomain.tld/api.php returns valid-looking json:
Yet homer/PiHole.vue fails with SyntaxError: Unexpected token F in JSON at position 0 PiHole.vue:71