Add protected admin diagnostics endpoint#28
Open
Spbd1 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
GET /api/admin/diagnosticsatapp/api/admin/diagnostics/route.tsthat requires the sameADMIN_EXPORT_TOKENbearer auth and returns only safe JSON fields (environment, app version, times, booleans, numeric limits, latest/total submission metrics) and never reveals secret values or URLs.prisma.$queryRaw\SELECT 1`and gatherscount()and latestsubmittedAtwithfindFirst(); when the DB is configured but unreachable the route returns a safe payload with{ ok: false, error: "Database is configured but unreachable." }and status503`.adminJsonResponse(which appliesCache-Control: no-store) andvalidateAdminRequestfromlib/adminAuth.server.tsto enforce the same token rules and safe headers.DEFAULT_ADMIN_EXPORT_TOKENfromlib/adminAuth.server.tsso diagnostics can report whether the configured token still uses the placeholder without exposing token values.components/admin/AdminDashboard.tsxthat fetches/api/admin/diagnosticsafter token entry, shows status badges and safe details, and includes a copyablecurlexample.Testing
app/api/admin/diagnostics/route.ts,lib/adminAuth.server.ts,components/admin/AdminDashboard.tsx.npm run typecheck(succeeded),npm run lint(succeeded; project already shows an unrelated React Hook warning incomponents/ParticipantBackgroundForm.tsx),npm run build(Next.js build succeeded).curl -H "Authorization: Bearer TOKEN" https://domain.com/api/admin/diagnostics.401for missing/invalid token), returns503with a safe message when DB is configured but unreachable, and setsCache-Control: no-storeon responses.Codex Task