# Tech-Spec: Fix API URL Configuration Issue **Created:** December 23, 2025 **Status:** Ready for Development ## Overview ### Problem Statement The frontend application is configured to use a hardcoded Hugging Face Space URL (`https://zelyanoth-lin-cbfcff2.hf.space`) instead of the user's local server IP address (`http://46.62.218.169/`). This causes API requests to fail with 404 errors when users try to access endpoints like `/api/posts/jobs/{jobId}`. ### Solution Update the frontend environment configuration to use the correct API URL that matches the user's server IP address instead of the hardcoded Hugging Face Space URL. ### Scope (In/Out) **In Scope:** - Update frontend environment configuration files to use correct API URL - Ensure API requests are made to the user's server IP address (`http://46.62.218.169/`) - Test that API endpoints work correctly after configuration change **Out Scope:** - Backend server modifications - Database schema changes - UI/UX modifications ## Context for Development ### Codebase Patterns - Frontend uses Vite with environment variables for configuration - API calls are made through axios with a base URL configuration - The project follows a standard React + Flask architecture ### Files to Reference - `frontend/.env.production` - Contains the hardcoded Hugging Face Space URL - `frontend/src/services/apiClient.js` - Contains the API client configuration logic - `frontend/src/services/api.js` - Contains additional API configuration ### Technical Decisions - The API URL should be configurable via environment variables to support different deployment environments - The production environment file should be updated to use the correct server IP address - CORS configuration in the backend already supports multiple origins including local addresses ## Implementation Plan ### Tasks - [x] Update `frontend/.env.production` to use correct API URL - [x] Verify that the API client properly handles the new URL configuration - [x] Test that API requests are made to the correct server IP address - [x] Verify that job polling endpoints work correctly ### Acceptance Criteria - [x] AC 1: Given the updated configuration, when a user clicks the button to generate a post, then API requests should be made to `http://46.62.218.169/api/posts/` instead of the Hugging Face Space URL - [x] AC 2: Given the updated configuration, when a user polls for job status, then requests to `/api/posts/jobs/{jobId}` should succeed without 404 errors - [x] AC 3: Given the updated configuration, when the application runs in production mode, then all API calls should use the correct server IP address ## Additional Context ### Dependencies - Frontend build process needs to be run after environment variable changes - Backend server must be accessible at the configured IP address ### Testing Strategy - Test the post generation flow after configuration changes - Verify that job polling works correctly - Check that all API endpoints return successful responses ### Notes - The backend is already configured to accept requests from various origins including local addresses - The frontend uses environment variables to determine the API URL based on the environment - The hardcoded URL in the production environment file needs to be changed to the user's server IP