Add daily Vercel Cron for scheduled docs reindex#9
Merged
Conversation
Vercel Cron triggers endpoints via GET, but the reindex logic lived only
on POST. Extract the reindex into a shared runReindex() helper and have
the GET handler run it when the request is authorized (Vercel injects
Authorization: Bearer ${CRON_SECRET}); unauthenticated GET still returns
the plain status check. POST behavior is unchanged.
Add a crons entry to vercel.json to hit /api/cron/reindex daily at
06:00 UTC. This is a safety net for missed GitHub webhooks; the freshness
guard skips when docs are unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a daily Vercel Cron trigger to the docs reindex endpoint to ensure reindexing still happens if GitHub webhooks are missed, by enabling authorized GET requests to run the same reindex logic as POST.
Changes:
- Add a daily (06:00 UTC) Vercel Cron schedule for the reindex endpoint.
- Refactor cron route logic by extracting a shared
runReindex()helper and invoking it from authorized GET requests. - Keep unauthenticated GET as a status check while preserving existing POST behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
vercel.json |
Registers a daily Vercel Cron job calling the reindex API route. |
app/api/cron/reindex/route.ts |
Extracts shared reindex execution into runReindex() and enables authorized GET-triggered reindexing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+84
to
+94
| export async function GET(request: NextRequest) { | ||
| if (getConfiguredSecret() && isAuthorizedReindexRequest(request)) { | ||
| return runReindex(request); | ||
| } | ||
|
|
||
| return NextResponse.json({ | ||
| status: "ok", | ||
| endpoint: "scheduled docs reindex", | ||
| configured: Boolean(getConfiguredSecret()), | ||
| }); | ||
| } |
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.
Adds a daily Vercel Cron (06:00 UTC) triggering the docs reindex as a safety net for missed GitHub webhooks. Vercel Cron triggers via GET, but reindex logic lived only on POST; this extracts a shared runReindex() helper and has GET run it when authorized (Vercel injects Authorization: Bearer CRON_SECRET, validated against REINDEX_SECRET || CRON_SECRET). Unauthenticated GET still returns the status check; POST unchanged. vercel.json gains a crons entry. Deploy note: CRON_SECRET must be set in Vercel Production (same value as REINDEX_SECRET). tsc clean; built in an isolated worktree.
🤖 Generated with Claude Code