vxkyyy commited on
Commit
48a46b4
·
1 Parent(s): 4074a23

feat: connect frontend to HuggingFace Space backend

Browse files

- VITE_API_BASE_URL in web/.env.example now points to HF Space
- Fix fallback from localhost:8000 → localhost:7860 in all pages
- Add vite proxy so local dev frontend → local Docker backend
- web/.env (localhost:7860) for local dev, excluded from git

web/.env.example CHANGED
@@ -1,5 +1,11 @@
1
  # AgentIC Web Frontend Environment Variables
2
 
3
- # The public URL of your fastAPI backend (running via ngrok or cloud server)
4
- # If left blank, it defaults to http://localhost:8000
5
- VITE_API_BASE_URL=https://exultingly-subchorionic-chante.ngrok-free.dev
 
 
 
 
 
 
 
1
  # AgentIC Web Frontend Environment Variables
2
 
3
+ # Production: HuggingFace Space URL
4
+ # VITE_API_BASE_URL=https://vxkyyy-agentIC.hf.space
5
+
6
+ # Local development: Docker container
7
+ # VITE_API_BASE_URL=http://localhost:7860
8
+
9
+ # If left blank, the Vite proxy handles it automatically during local dev
10
+ # and falls back to http://localhost:7860
11
+ VITE_API_BASE_URL=
web/.gitignore CHANGED
@@ -11,6 +11,9 @@ node_modules
11
  dist
12
  dist-ssr
13
  *.local
 
 
 
14
 
15
  # Editor directories and files
16
  .vscode/*
 
11
  dist
12
  dist-ssr
13
  *.local
14
+ .env
15
+ .env.*
16
+ !.env.example
17
 
18
  # Editor directories and files
19
  .vscode/*
web/src/App.tsx CHANGED
@@ -26,7 +26,7 @@ const App = () => {
26
  }, [theme]);
27
 
28
  useEffect(() => {
29
- const API_BASE_URL = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000').replace(/\/$/, '');
30
  axios.get(`${API_BASE_URL}/designs`)
31
  .then(res => {
32
  const data = res.data?.designs || [];
 
26
  }, [theme]);
27
 
28
  useEffect(() => {
29
+ const API_BASE_URL = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:7860').replace(/\/$/, '');
30
  axios.get(`${API_BASE_URL}/designs`)
31
  .then(res => {
32
  const data = res.data?.designs || [];
web/src/components/BuildMonitor.tsx CHANGED
@@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react';
2
  import { motion } from 'framer-motion';
3
  import axios from 'axios';
4
 
5
- const API = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000').replace(/\/$/, '');
6
 
7
  const STATES_DISPLAY: Record<string, { label: string; icon: string }> = {
8
  INIT: { label: 'Initializing Workspace', icon: '🔧' },
 
2
  import { motion } from 'framer-motion';
3
  import axios from 'axios';
4
 
5
+ const API = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:7860').replace(/\/$/, '');
6
 
7
  const STATES_DISPLAY: Record<string, { label: string; icon: string }> = {
8
  INIT: { label: 'Initializing Workspace', icon: '🔧' },
web/src/pages/Dashboard.tsx CHANGED
@@ -17,7 +17,7 @@ export const Dashboard: React.FC<DashboardProps> = ({ selectedDesign }) => {
17
  if (!selectedDesign) return;
18
  setLoading(true);
19
 
20
- const API_BASE_URL = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000').replace(/\/$/, '');
21
 
22
  // Fetch Quick Metrics
23
  axios.get(`${API_BASE_URL}/metrics/${selectedDesign}`)
 
17
  if (!selectedDesign) return;
18
  setLoading(true);
19
 
20
+ const API_BASE_URL = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:7860').replace(/\/$/, '');
21
 
22
  // Fetch Quick Metrics
23
  axios.get(`${API_BASE_URL}/metrics/${selectedDesign}`)
web/src/pages/DesignStudio.tsx CHANGED
@@ -5,7 +5,7 @@ import { BuildMonitor } from '../components/BuildMonitor';
5
  import { ChipSummary } from '../components/ChipSummary';
6
  import { fetchEventSource } from '@microsoft/fetch-event-source';
7
 
8
- const API = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000').replace(/\/$/, '');
9
 
10
  type Phase = 'prompt' | 'building' | 'done';
11
 
 
5
  import { ChipSummary } from '../components/ChipSummary';
6
  import { fetchEventSource } from '@microsoft/fetch-event-source';
7
 
8
+ const API = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:7860').replace(/\/$/, '');
9
 
10
  type Phase = 'prompt' | 'building' | 'done';
11
 
web/src/pages/Documentation.tsx CHANGED
@@ -3,7 +3,7 @@ import axios from 'axios';
3
  import ReactMarkdown from 'react-markdown';
4
  import remarkGfm from 'remark-gfm';
5
 
6
- const API = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000').replace(/\/$/, '');
7
 
8
  interface DocItem {
9
  id: string;
 
3
  import ReactMarkdown from 'react-markdown';
4
  import remarkGfm from 'remark-gfm';
5
 
6
+ const API = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:7860').replace(/\/$/, '');
7
 
8
  interface DocItem {
9
  id: string;
web/src/pages/HumanInLoopBuild.tsx CHANGED
@@ -6,7 +6,7 @@ import { StageProgressBar } from '../components/StageProgressBar';
6
  import { ApprovalCard } from '../components/ApprovalCard';
7
  import '../hitl.css';
8
 
9
- const API = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000').replace(/\/$/, '');
10
 
11
  const PIPELINE_STAGES = [
12
  'INIT', 'SPEC', 'RTL_GEN', 'RTL_FIX', 'VERIFICATION', 'FORMAL_VERIFY',
 
6
  import { ApprovalCard } from '../components/ApprovalCard';
7
  import '../hitl.css';
8
 
9
+ const API = (import.meta.env.VITE_API_BASE_URL || 'http://localhost:7860').replace(/\/$/, '');
10
 
11
  const PIPELINE_STAGES = [
12
  'INIT', 'SPEC', 'RTL_GEN', 'RTL_FIX', 'VERIFICATION', 'FORMAL_VERIFY',
web/vite.config.ts CHANGED
@@ -4,4 +4,14 @@ import react from '@vitejs/plugin-react'
4
  // https://vite.dev/config/
5
  export default defineConfig({
6
  plugins: [react()],
 
 
 
 
 
 
 
 
 
 
7
  })
 
4
  // https://vite.dev/config/
5
  export default defineConfig({
6
  plugins: [react()],
7
+ server: {
8
+ proxy: {
9
+ // When VITE_API_BASE_URL is not set, proxy /api/* to the local Docker backend
10
+ '/api': {
11
+ target: 'http://localhost:7860',
12
+ changeOrigin: true,
13
+ rewrite: (path) => path.replace(/^\/api/, ''),
14
+ },
15
+ },
16
+ },
17
  })