Spaces:
Running
Running
File size: 908 Bytes
c2ea5ed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
// API configuration with environment support
export const getApiBase = () => {
// In Docker development environment, use the environment variable if available
if (import.meta.env.VITE_API_URL) {
console.log("Using VITE_API_URL:", import.meta.env.VITE_API_URL);
return import.meta.env.VITE_API_URL;
}
// Check if we're in a Docker environment by looking at hostname
if (
typeof window !== "undefined" &&
window.location.hostname !== "localhost" &&
window.location.hostname !== "127.0.0.1"
) {
const dockerApiUrl = `http://${window.location.hostname}:5280/api`;
console.log("Using Docker API URL:", dockerApiUrl);
// If accessing via Docker host IP, try to use the backend port directly
return dockerApiUrl;
}
// Default to proxy for local development
console.log("Using proxy API URL: /api");
return "/api";
};
export const API_BASE = getApiBase();
|