fixed routes
All checks were successful
Build Frontend / Build Frontend (push) Successful in 24s

This commit is contained in:
2026-01-11 02:54:27 +00:00
parent e549e77811
commit ef987f54b0

View File

@@ -2,9 +2,37 @@ import axios from "axios";
import { useAuthStore } from "@/stores/auth"; import { useAuthStore } from "@/stores/auth";
import { useToast } from "vue-toastification"; import { useToast } from "vue-toastification";
// Get the API base URL
const getApiBaseUrl = () => {
// If VITE_API_URL is set, use it
if (import.meta.env.VITE_API_URL) {
return import.meta.env.VITE_API_URL;
}
// In production, use the api subdomain
if (import.meta.env.PROD) {
const currentHost = window.location.hostname;
const protocol = window.location.protocol;
// If on turbotrades.dev, use api.turbotrades.dev
if (
currentHost === "turbotrades.dev" ||
currentHost === "www.turbotrades.dev"
) {
return `${protocol}//api.turbotrades.dev/api`;
}
// For other domains, try api subdomain
return `${protocol}//api.${currentHost}/api`;
}
// In development, use relative path (Vite proxy handles it)
return "/api";
};
// Create axios instance // Create axios instance
const axiosInstance = axios.create({ const axiosInstance = axios.create({
baseURL: import.meta.env.VITE_API_URL || "/api", baseURL: getApiBaseUrl(),
timeout: 15000, timeout: 15000,
withCredentials: true, withCredentials: true,
headers: { headers: {