fix: add error handling and local dev fallback for auth
Build & Push Portfolio Image / build-push (push) Successful in 3m26s
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:
+12
-2
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user