fix: centralize API URL configuration in constants

- Move API base URL to single constant in @/constants/api
- Update all API modules to import from centralized location
- Ensure consistent port 8080 usage across frontend
- Support VITE_API_URL environment variable for flexible deployment
This commit is contained in:
Chris Scott committed 2025-11-24 00:17:05 -05:00
1 parent e4e255b2bc
commit 1555a6d641
7 files changed
+19 -9

No files matched your search

+1 -2
View File
@@ -1,7 +1,6 @@
import { settingsApi } from "./settings";
import axios from "axios";
const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:5001";
import { API_BASE_URL } from "@/constants/api";
export interface Model {
id: string;
+2 -1
View File
@@ -1,6 +1,7 @@
import type { Repo } from './types'
import { API_BASE_URL } from '@/constants/api'
const API_BASE = import.meta.env.VITE_API_URL ?? 'http://localhost:5001'
const API_BASE = API_BASE_URL
export async function createRepo(
repoUrl: string,
+1 -2
View File
@@ -7,8 +7,7 @@ import type {
CreateOpenCodeConfigRequest,
UpdateOpenCodeConfigRequest
} from './types/settings'
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:5001'
import { API_BASE_URL } from '@/constants/api'
export const settingsApi = {
getSettings: async (userId = 'default'): Promise<SettingsResponse> => {
@@ -8,8 +8,9 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { FolderOpen, Upload, RefreshCw, X } from 'lucide-react'
import type { FileInfo } from '@/types/files'
import { API_BASE_URL } from '@/constants/api'
const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:5001'
const API_BASE = API_BASE_URL
// Hook to detect mobile screens
const useIsMobile = () => {
@@ -2,8 +2,9 @@ import { useState } from 'react'
import { Button } from '@/components/ui/button'
import { Download, Copy, X, Edit3, Save, X as XIcon } from 'lucide-react'
import type { FileInfo } from '@/types/files'
import { API_BASE_URL } from '@/constants/api'
const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:5001'
const API_BASE = API_BASE_URL
interface FilePreviewProps {
file: FileInfo
+5 -1
View File
@@ -1 +1,5 @@
export const OPENCODE_API_ENDPOINT = '/api/opencode'
export const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:8080'
export const OPENCODE_API_ENDPOINT = import.meta.env.VITE_API_URL
? `${import.meta.env.VITE_API_URL}/api/opencode`
: '/api/opencode'
+6 -1
View File
@@ -17,7 +17,12 @@ export default defineConfig({
server: {
host: '0.0.0.0',
port: 5173,
proxy: {
proxy: process.env.VITE_API_URL ? {
'/api': {
target: process.env.VITE_API_URL,
changeOrigin: true,
},
} : {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,