Skip to content

Colota - Android GPS Location tracker

fix: use correct geopulse health check endpoint /api/health Closes #300

Max Dietrichec6ec97f272e
diff --git a/apps/mobile/src/utils/__tests__/healthCheck.test.ts b/apps/mobile/src/utils/__tests__/healthCheck.test.ts
index 287bd112..fefdeee1 100644
--- a/apps/mobile/src/utils/__tests__/healthCheck.test.ts
+++ b/apps/mobile/src/utils/__tests__/healthCheck.test.ts
@@ -29,9 +29,9 @@ describe("resolveHealthUrls", () => {
])
})
- it("geopulse: tries /health then origin", () => {
+ it("geopulse: tries /api/health then origin", () => {
expect(resolveHealthUrls("http://geopulse.local/ingest", "geopulse")).toEqual([
- "http://geopulse.local/health",
+ "http://geopulse.local/api/health",
"http://geopulse.local"
])
})
diff --git a/apps/mobile/src/utils/healthCheck.ts b/apps/mobile/src/utils/healthCheck.ts
index 93672d68..f0cd2723 100644
--- a/apps/mobile/src/utils/healthCheck.ts
+++ b/apps/mobile/src/utils/healthCheck.ts
@@ -1,20 +1,16 @@
import { ApiTemplateName } from "../types/global"
-/**
- * Resolves an ordered list of URLs to try for server health/reachability checks.
- * Each backend exposes connectivity differently - known endpoints are tried first,
- * with the origin root as a final fallback to confirm basic connectivity.
- */
+// Returns URLs to try in order: known health path first, origin root as fallback.
export function resolveHealthUrls(endpoint: string, apiTemplate: ApiTemplateName): string[] {
try {
const origin = new URL(endpoint).origin
switch (apiTemplate) {
case "traccar": {
- // Prefer Traccar web API port; fall back to OsmAnd port (returns 400 but confirms reachability)
- const match = endpoint.match(/^(https?:\/\/[^/:]+)/)
- const host = match ? match[1] : origin
- return [`${host}:8082/api/server`, `${host}:8082`]
+ // Traccar web API runs on port 8082 regardless of the OsmAnd ingest port (5055)
+ const { protocol, hostname } = new URL(endpoint)
+ const base = `${protocol}//${hostname}:8082`
+ return [`${base}/api/server`, base]
}
case "dawarich":
return [`${origin}/api/v1/health`, origin]
@@ -25,8 +21,10 @@ export function resolveHealthUrls(endpoint: string, apiTemplate: ApiTemplateName
// PhoneTrack is a Nextcloud app - use Nextcloud's status endpoint
return [`${origin}/status.php`, origin]
case "geopulse":
+ return [`${origin}/api/health`, origin]
case "reitti":
case "custom":
+ // no UI yet for adding custom healthcheck endpoints; could be added once the server conenction settings get a own screen
default:
return [`${origin}/health`, origin]
}