fix: 使用环境变量设置baseurl

This commit is contained in:
oliviamn 2025-05-27 23:39:01 +08:00
parent c3fc9459b8
commit 3afe01f5f2
2 changed files with 7 additions and 8 deletions

13
frontend/src/env.d.ts vendored
View File

@ -1,9 +1,8 @@
/// <reference types="vite/client" />
/// <reference types="react-scripts" />
interface ImportMetaEnv {
readonly VITE_API_BASE_URL: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
declare namespace NodeJS {
interface ProcessEnv {
readonly REACT_APP_API_BASE_URL: string;
// Add other environment variables here
}
}

View File

@ -1,7 +1,7 @@
import axios from 'axios';
import { File, FileUploadResponse } from '../types/file';
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000/api/v1';
const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || 'http://localhost:8000/api/v1';
// Create axios instance with default config
const axiosInstance = axios.create({