fix: use public Pi-hole version discovery (#7032)
This commit is contained in:
1 parent
3bd8101b36
commit
b7b803816c
2 files changed
+5
-4
No files matched your search
@@ -15,7 +15,8 @@ import { piHoleIntegration } from ".";
|
||||
<IntegrationHeader integration={piHoleIntegration} categories={["DNS Hole"]} />
|
||||
|
||||
<Alert type="note" className="my-2">
|
||||
Homarr supports both Pi-hole v5 and v6. It automatically detects the version and uses the correct API.
|
||||
Homarr supports both Pi-hole v5 and v6. It automatically detects the version and uses the correct API. If your reverse
|
||||
proxy restricts API paths, allow the public `/api/info/login` endpoint used to detect Pi-hole v6.
|
||||
</Alert>
|
||||
|
||||
### Widgets & Capabilities
|
||||
|
||||
@@ -8,13 +8,13 @@ import { PiHoleIntegrationV6 } from "./v6/pi-hole-integration-v6";
|
||||
export const createPiHoleIntegrationAsync = async (input: IntegrationInput) => {
|
||||
try {
|
||||
const baseUrl = removeTrailingSlash(input.url);
|
||||
const url = new URL(`${baseUrl}/api/info/version`);
|
||||
const url = new URL(`${baseUrl}/api/info/login`);
|
||||
const response = await fetchWithTrustedCertificatesAsync(url);
|
||||
|
||||
/**
|
||||
* In pi-hole 5 the api was at /admin/api.php, in pi-hole 6 it was moved to /api
|
||||
* For the /api/info/version endpoint, the response is 404 in pi-hole 5
|
||||
* and 401 in pi-hole 6
|
||||
* The public /api/info/login endpoint returns 404 in pi-hole 5
|
||||
* and 200 in pi-hole 6, without requiring an authenticated session.
|
||||
*/
|
||||
if (response.status === 404) {
|
||||
return new PiHoleIntegrationV5(input);
|
||||
|
||||
Reference in new issue
Block a user