From 6a9cb5b488c42bdae32b4871153f8c04dad6ff4e Mon Sep 17 00:00:00 2001 From: ricardo-agz Date: Wed, 22 Oct 2025 16:18:18 -0700 Subject: [PATCH] added error message when env var missing --- python/vibe-coding-ide/README.md | 2 +- .../frontend/src/hooks/useChat.tsx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/python/vibe-coding-ide/README.md b/python/vibe-coding-ide/README.md index cb804f0ffa..8d3b2ce7d5 100644 --- a/python/vibe-coding-ide/README.md +++ b/python/vibe-coding-ide/README.md @@ -31,4 +31,4 @@ npm i npm run dev ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the backend. +Open [http://localhost:3000](http://localhost:3000) with your browser to see the frontend. diff --git a/python/vibe-coding-ide/frontend/src/hooks/useChat.tsx b/python/vibe-coding-ide/frontend/src/hooks/useChat.tsx index 072617fd93..9c3926893f 100644 --- a/python/vibe-coding-ide/frontend/src/hooks/useChat.tsx +++ b/python/vibe-coding-ide/frontend/src/hooks/useChat.tsx @@ -5,6 +5,8 @@ import { API_BASE } from '../constants' import { useProjects } from '../context/ProjectsContext' import { computeProjectHashes } from '../lib/hash' +declare const process: { env: Record } + interface UseChatProps { userId: string input: string @@ -44,6 +46,22 @@ export const useChat = ({ useProjects() const sendPrompt = useCallback(async () => { if (!input.trim()) return + // In production, require NEXT_PUBLIC_API_URL to be set; otherwise show a user-facing error + const isProd = (process.env.NODE_ENV || '').trim() === 'production' + const hasApiUrl = Boolean((process.env.NEXT_PUBLIC_API_URL || '').trim()) + if (isProd && !hasApiUrl) { + const errorRunId = `config_error_${Date.now()}` + createRun(errorRunId, input, projectId, threadId) + addAction(errorRunId, { + id: `notice_${Date.now()}`, + kind: 'system_notice', + status: 'done', + message: + 'Missing environment variable: NEXT_PUBLIC_API_URL is not set. Set it to your backend URL and reload.', + timestamp: new Date().toISOString(), + } as Action) + return + } setLoading(true) setInput('')