Skip to content

docs(env): CRON_SECRET missing from .env.example (internal endpoints 401 in cloud) #244

Closed

Description

@gkhngyk

Summary

CRON_SECRET is required to operate the app in cloud mode, but it is missing from both .env.example files — so nothing reminds an operator to set it, and the internal endpoints permanently return 401.

Where it's used

Server — guards three internal endpoints (server/src/server.js):

  • server.js:155 — /api/internal/daily-tracking
  • server.js:177 — /api/internal/content/:id/brief
  • server.js:213 — /api/internal/trigger-tracking

Each guard is if (!process.env.CRON_SECRET || secret !== process.env.CRON_SECRET) → 401. When the var is unset, the first clause is always true, so every call to these endpoints returns 401 no matter what the caller sends.

These are documented as CRON_SECRET-protected in server/README.md (the internal-endpoints table).

Web — sends / checks the same secret (must match the server's value):

  • web/src/app/api/cron/daily-tracking/route.ts — Vercel Cron entrypoint
  • web/src/app/api/stripe/success/route.ts — post-checkout tracking trigger
  • web/src/lib/mcp/data.ts — MCP brief generation (throws CRON_SECRET must be configured when missing)

Impact

In a cloud deploy, if the operator never sets CRON_SECRET (because it isn't in the example files), daily tracking cron, content-brief generation, and post-checkout tracking all fail — the server side 401s and the MCP path throws. Self-hosted/local users who never hit these paths won't notice, which is why it's easy to miss.

Suggested fix

Add a documented CRON_SECRET entry to both example files:

Include a comment noting that:

  • it's cloud-only (needed when Vercel Cron / the Stripe success route / the MCP layer call the server's internal endpoints), and
  • the same value must be set on both the web app and the server, since the web side sends Authorization: Bearer ${CRON_SECRET} and the server compares against its own copy.

Docs/config only — no code changes.

Activity

  1. added a commit that references this issue on Jun 19, 2026
    62be42a
  2. added a commit that references this issue on Jun 19, 2026
    9fb33d7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions