Skip to content

fix(nextjs): accept KAK_API_KEY so the Deploy button works#3

Merged
nqzai merged 1 commit into
mainfrom
fix/nextjs-deploy-api-key-env
Jul 8, 2026
Merged

fix(nextjs): accept KAK_API_KEY so the Deploy button works#3
nqzai merged 1 commit into
mainfrom
fix/nextjs-deploy-api-key-env

Conversation

@nqzai

@nqzai nqzai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Problem

The Next.js sample's Deploy to Vercel button (and the Vercel Marketplace integration) injects the API key as KAK_API_KEY, but nextjs/lib/kakunin.ts read only process.env.KAKUNIN_API_KEY!. Result: a one-click deploy boots with an undefined key and throws on the first SDK call — the advertised zero-config path ships broken.

Fix

  • lib/kakunin.ts — read KAK_API_KEY ?? KAKUNIN_API_KEY; throw a clear, actionable error (with the dashboard link) when neither is set, instead of a cryptic non-null-assertion crash.
  • README.md — note the init reads either variable.
  • .env.example — document that both are accepted and that Vercel injects KAK_API_KEY.

Both paths now work: Deploy button (KAK_API_KEY) and local dev (KAKUNIN_API_KEY).

Verification

Sample has no build harness; change is trivially sound TS — ?? yields string | undefined, the guard throws on falsy, and apiKey narrows to string before construction.

🤖 Generated with Claude Code

The Deploy-to-Vercel button injects KAK_API_KEY (matching the Vercel
Marketplace integration), but lib/kakunin.ts read only KAKUNIN_API_KEY,
so one-click deploys booted with an undefined key and crashed on the
first SDK call. Read KAK_API_KEY ?? KAKUNIN_API_KEY and throw a clear,
actionable error when neither is set. Docs + .env.example updated to
note both are accepted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nqzai
nqzai merged commit 29f38a8 into main Jul 8, 2026
2 checks passed
@nqzai
nqzai deleted the fix/nextjs-deploy-api-key-env branch July 8, 2026 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant