Skip to content

Commit f1abfd1

Browse files
committed
expose health/indexer-progress + add /api/* redirects on ordpool.space
Two related changes: 1. Rename /api/v1/internal/indexer-progress → /api/v1/health/indexer-progress and drop the localhost gate. The gate was a no-op anyway: cloudflared forwards to 127.0.0.1:8999 on happysrv, so every public request already passes the isLocal check. Body is non-sensitive operational data (lastSuccessAt, lagMinutes, skippedCount) — safe to expose. Renaming clarifies the intent: this is a health endpoint. 2. Add 301 redirects on Pages for /api/* and /api/v1/* → api.ordpool.space. ordpool is a mempool fork; users follow mempool's docs and expect those examples to work against ordpool.space too. The v2 SPA uses absolute apiBaseUrl, so this only matters for external API consumers (curl, scripts, the upstream docs and FAQ examples). Updated comment in ordpool-missing-stats.ts referring to the old path. healthcheck-ping.sh path bump ships separately (deploy-happyserver repo).
1 parent eed7ef7 commit f1abfd1

3 files changed

Lines changed: 21 additions & 16 deletions

File tree

‎backend/src/api/explorer/_ordpool/ordpool.routes.ts‎

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { Aggregation, ChartType, Interval } from './ordpool-statistics-interface
99
import ordpoolStatisticsApi from './ordpool-statistics.api';
1010

1111
/** If the indexer hasn't recorded a per-block success in this many minutes,
12-
* the /internal/indexer-progress endpoint returns 503 and the heartbeat
13-
* script (deploy-happyserver/scripts/healthcheck-ping.sh) skips its OK ping,
12+
* /api/v1/health/indexer-progress returns 503 and the heartbeat script
13+
* (deploy-happyserver/scripts/healthcheck-ping.sh) skips its OK ping,
1414
* triggering a Healthchecks.io grace-expiry alert. */
1515
const MAX_LAG_MINUTES = 30;
1616

@@ -19,26 +19,21 @@ class GeneralOrdpoolRoutes {
1919
public initRoutes(app: Application): void {
2020
app
2121
.get(config.MEMPOOL.API_URL_PREFIX + 'ordpool/statistics/:type/:interval/:aggregation', this.$getOrdpoolStatistics)
22-
.get(config.MEMPOOL.API_URL_PREFIX + 'internal/indexer-progress', this.$getIndexerProgress)
22+
.get(config.MEMPOOL.API_URL_PREFIX + 'health/indexer-progress', this.$getIndexerProgress)
2323
.get('/content/:inscriptionId', this.getInscriptionContent)
2424
.get('/preview/:inscriptionId', this.getInscriptionPreview);
2525
}
2626

2727
/**
28-
* Internal liveness endpoint. Returns 200 with the indexer's last-success
29-
* timestamp + skipped-block count when the indexer is making progress
30-
* (lag < MAX_LAG_MINUTES). Returns 503 when stale. Localhost-only — the
31-
* cloudflared tunnel forwards /api/v1/* but production access from the
32-
* outside is rejected here, since this endpoint exposes internal state.
28+
* Public health endpoint. Returns 200 with the indexer's last-success
29+
* timestamp + skipped-block count when the missing-stats indexer is making
30+
* progress (lag <= MAX_LAG_MINUTES); 503 when stale. The body is
31+
* non-sensitive operational data — safe for the heartbeat script to poll
32+
* locally and for users to view in the browser.
33+
*
34+
* @returns JSON `{ ok, lastSuccessAt, lagMinutes, maxLagMinutes, skippedCount }`.
3335
*/
3436
private async $getIndexerProgress(req: Request, res: Response): Promise<void> {
35-
const remote = req.ip || req.socket.remoteAddress || '';
36-
const isLocal = remote === '127.0.0.1' || remote === '::1' || remote === '::ffff:127.0.0.1';
37-
if (!isLocal) {
38-
res.status(403).send('Forbidden');
39-
return;
40-
}
41-
4237
try {
4338
const lastSuccessAt = OrdpoolMissingStats.getLastSuccessAt();
4439
const skippedCount = await ordpoolSkippedBlocksRepository.getSkippedCount();

‎backend/src/api/ordpool-missing-stats.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class OrdpoolMissingStats {
7171

7272
/**
7373
* Wall-clock timestamp of the last per-block successful save. Read by the
74-
* /api/v1/internal/indexer-progress route to prove the indexer is making
74+
* /api/v1/health/indexer-progress route to prove the indexer is making
7575
* progress; the heartbeat script alerts when this goes stale.
7676
*/
7777
private lastSuccessAt: number | null = null;

‎frontend/src/_redirects‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
/content/* https://api.ordpool.space/content/:splat 301
88
/preview/* https://api.ordpool.space/preview/:splat 301
99

10+
# mempool.space-shape /api/* URLs. ordpool is a mempool fork; users
11+
# follow mempool's docs and expect those examples to work against
12+
# ordpool.space too. The v2 SPA itself uses absolute apiBaseUrl
13+
# 'https://api.ordpool.space', so this 301 only fires for external
14+
# API consumers (curl, scripts, the upstream docs and FAQ).
15+
# WebSocket (/api/v1/ws) intentionally not listed — 301 doesn't carry
16+
# Upgrade headers; WS clients should connect to wss://api.ordpool.space.
17+
/api/v1/* https://api.ordpool.space/api/v1/:splat 301
18+
/api/* https://api.ordpool.space/api/:splat 301
19+
1020
# Recursion endpoints — sent to ordinals.com. cat21-ord runs with
1121
# --index-cat21 and only indexes cats, so it can't answer non-cat
1222
# recursive lookups. /r/* is the modern form; the four below are the

0 commit comments

Comments
 (0)