2026-01-05: Fix Dev Env & Error Handling
Task Metadata
Date: 2026-01-05
Status: Completed
1. Context
- Goal: Fix the configuration issue causing the deployed dev environment to connect to the Prod AppSync API, and improve the frontend error handling to display useful messages from the API.
- Trigger: User reported
FieldUndefinederrors on the deployed dev site (schema mismatch) and unhelpful "Error: [object Object]" UI messages.
2. Approach
-
Configuration (Environment Variables):
- Current State: API endpoints are hardcoded in
amplify.config.jswith simple boolean logic. - Target State: All environment-specific config (API URL, User Pool ID, etc.) will be loaded via standard
VITE_*environment variables. - Action:
- Create
frontend/.envfor local development defaults. - Refactor
frontend/src/amplify.config.jsto readimport.meta.env.VITE_API_ENDPOINT, etc. - Update Architecture docs to mandate setting these variables in CI/CD (Amplify Console).
- Create
- Current State: API endpoints are hardcoded in
-
Error Handling:
- The AppSync client returns a 200 OK response with an
errorsarray for GraphQL errors. - The current
ApiMealServicelikely doesn't check for thiserrorsarray or doesn't format it for the UI. - Fix:
- Update
ApiMealServiceto check forresponse.errors. If present, throw a formatted error (e.g., joining the messages). - Update
Dashboardto display this formatted string instead of the raw error object.
- Update
- The AppSync client returns a 200 OK response with an
3. Impact Analysis
- Files to Modify:
frontend/src/amplify.config.jsfrontend/src/services/ApiMealService.ts(or.js)frontend/src/pages/Dashboard.tsx(or.jsx)
- Risks:
- None. This is a fix for existing broken behavior in the dev environment.
4. Execution Plan
- Update
frontend/src/amplify.config.jsto supportVITE_APP_ENV. - Update
ApiMealServiceto throw meaningful errors fromresponse.errors. - Verify
Dashboarddisplays the error text correctly.