fix: add error handling and local dev fallback for auth
Build & Push Portfolio Image / build-push (push) Successful in 3m26s

- Handle getAccessToken failure gracefully
- Support LLM_API_TOKEN env var for local dev (bypasses OAuth)
- Better error messages for missing credentials
This commit is contained in:
Story Crater Bot
2026-09-03 20:38:42 -07:00
parent 32636832fc
commit d5f97d2073
2 changed files with 24 additions and 3 deletions
+12 -2
View File
@@ -135,9 +135,19 @@ GOOD example:
BAD: "Rock resolved the Terraform configuration drift issue by implementing automated drift detection and real-time visibility into discrepancies..." — this is garbage. Never do this.`
export async function POST(request: NextRequest) {
let token: string
try {
token = await getAccessToken()
} catch (error) {
console.error('Failed to get access token:', error)
return new Response(
JSON.stringify({ error: 'Authentication failed - check AUTHENTIK_CLIENT_ID/SECRET' }),
{ status: 500, headers: { 'Content-Type': 'application/json' } }
)
}
try {
// Get OAuth token (cached, auto-refreshes)
const token = await getAccessToken()
const { message } = await request.json()
const response = await fetch(LLM_API_URL, {