Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Coach disclosure names the host a job goes to

Duarte Santosc44b1ec2c7e2
diff --git a/api/coach/routes.js b/api/coach/routes.js
index 85c0c7eb1..0e090d3a4 100644
--- a/api/coach/routes.js
+++ b/api/coach/routes.js
@@ -24,6 +24,7 @@ const USER_ERROR = {
shared: cfgStore.SHARED_ACCOUNT_REFUSAL,
unprivileged: 'the Coach is switched off on this instance for safety reasons'
};
+const hostOf = url => { try { return url ? new URL(url).host : null; } catch { return null; } };
const HTTP_FOR = { off: 503, busy: 409, cap: 429, consent: 403, shared: 409, unprivileged: 503 };
export function coachRoutes({ json, readBody, readSession, requireAdmin }) {
@@ -54,6 +55,10 @@ export function coachRoutes({ json, readBody, readSession, requireAdmin }) {
json(res, 200, {
provider: cfg.provider,
providerLabel: cfgStore.providerMeta(cfg).label,
+ // Where an HTTPS provider's requests go, host only: the app asks once per provider and
+ // host before anything is sent there, and a compatible endpoint is only nameable by it.
+ // Never the path, and the base URL cannot carry credentials (validateBaseUrl).
+ host: hostOf(baseUrlFor(cfg.provider, cfg)),
categories: DATA_CATEGORIES,
version: 1
});
diff --git a/api/openapi.yaml b/api/openapi.yaml
index ca178cb63..ccb4a0572 100644
--- a/api/openapi.yaml
+++ b/api/openapi.yaml
@@ -2459,6 +2459,13 @@ paths:
properties:
provider: { type: string, description: "Provider id, e.g. `anthropic`." }
providerLabel: { type: string }
+ host:
+ type: string
+ nullable: true
+ description: >-
+ Host the provider's requests go to (an HTTPS provider's base URL, host and
+ port only), or null for a runtime provider. The app asks the user once per
+ provider and host before the first request.
categories:
type: array
items: { type: string, enum: [plan, training, bodyweight, profile, prefs] }
@@ -2467,6 +2474,7 @@ paths:
example:
provider: anthropic
providerLabel: Claude
+ host: api.anthropic.com
categories: [plan, training, bodyweight, profile, prefs]
version: 1
'401': { $ref: '#/components/responses/Unauthorized' }
diff --git a/api/test/routes.test.js b/api/test/routes.test.js
index 6070b19f0..0016a0cec 100644
--- a/api/test/routes.test.js
+++ b/api/test/routes.test.js
@@ -158,6 +158,23 @@ test('the disclosure names the provider and the same five categories the payload
assert.equal(r.status, 200);
assert.equal(r.body.providerLabel, 'Google Gemini');
assert.deepEqual(r.body.categories, ['plan', 'training', 'bodyweight', 'profile', 'prefs']);
+ assert.equal(r.body.host, 'generativelanguage.googleapis.com');
+});
+
+test('the disclosure says which host a job would go to, and nothing more of the URL', async () => {
+ fresh({ provider: 'compatible', providerOptions: { compatible: { baseUrl: 'https://llm.example.org:8443/v1' } } });
+ const { call } = harness();
+ let r = await call('GET /api/coach/disclosure');
+ assert.equal(r.status, 200);
+ assert.equal(r.body.provider, 'compatible');
+ assert.equal(r.body.host, 'llm.example.org:8443');
+ assert.ok(!JSON.stringify(r.body).includes('/v1'), 'no path, only the host');
+
+ // A runtime provider has no base URL to name; the app says the provider instead.
+ fresh({ provider: 'claude' });
+ r = await call('GET /api/coach/disclosure');
+ assert.equal(r.body.host, null);
+ assert.equal(r.body.providerLabel, 'Claude (Anthropic)');
});
/* ---------- debrief + cohort routes ---------- */