mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
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:
1 parent
e4e255b2bc
commit
1555a6d641
7 files changed
+19
-9
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user