fix(hub): BIT-31442 route /v1/paperclip alias to admin API + accept X-Api-Key header
The recent-errors handler (api/src/routes/public/recentErrors.ts) registers both GET /api/error-monitoring/recent-errors and the alias GET /v1/paperclip/recent-errors on the admin API (port 3200). However the admin-ui Next.js rewrite sent all /v1/* to ingest-api (port 3041), which has no such route, so the alias returned 404 in production while the /api/error-monitoring path worked (401 without a key). Changes: - admin-ui/next.config.ts: add a specific /v1/paperclip/:path* -> admin API rewrite before the generic /v1/:path* -> ingest-api rule (rewrite order matters; first match wins). - api/src/lib/errorMonitoringAuth.ts: authorizeReadQuery now also accepts an X-Api-Key header carrying either ERROR_RESOLVE_API_KEY/ERROR_REPORTING_API_KEY or DEBUG_VIEW_ERRORS_KEY, so programmatic callers avoid leaking keys in URLs/access logs. Backward compatible with the existing query params. - api/src/routes/public/recentErrors.test.ts: cover the alias path and the X-Api-Key header (resolve key, view key, invalid key). - docs/HTTP_CONTRACTS.md, docs/permission-matrix.md: document the header and the proxy ordering requirement.
This commit is contained in:
1 parent
954b0ced2e
commit
d4059d801a
5 files changed
+89
-1
No files matched your search
@@ -23,6 +23,15 @@ const nextConfig: NextConfig = {
|
||||
async rewrites() {
|
||||
return [
|
||||
{ source: "/health", destination: `${INGEST_API_URL}/health` },
|
||||
// BIT-31442: the recent-errors handler (api/src/routes/public/recentErrors.ts)
|
||||
// registers the /v1/paperclip/recent-errors alias on the admin API (port 3200),
|
||||
// not on ingest-api. The generic /v1/* rule below would otherwise send it to
|
||||
// ingest-api (port 3041), which has no such route and returns 404. This more
|
||||
// specific rule must come first; Next.js evaluates rewrites in order.
|
||||
{
|
||||
source: "/v1/paperclip/:path*",
|
||||
destination: `${ADMIN_API_URL}/v1/paperclip/:path*`,
|
||||
},
|
||||
{ source: "/v1/:path*", destination: `${INGEST_API_URL}/v1/:path*` },
|
||||
{
|
||||
source: "/api/error-monitoring/:path*",
|
||||
|
||||
Reference in new issue
Block a user