Fix jwt-token
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_BASE_URL = import.meta.env.VITE_API_URL ||
|
||||
(process.env.NODE_ENV === 'production'
|
||||
? '/drones/api'
|
||||
: 'http://localhost:3002/api');
|
||||
// Determine API base URL based on environment
|
||||
const getApiBaseUrl = () => {
|
||||
// If VITE_API_URL is explicitly set, use it
|
||||
if (import.meta.env.VITE_API_URL) {
|
||||
return import.meta.env.VITE_API_URL;
|
||||
}
|
||||
|
||||
// If we're on localhost, use localhost API
|
||||
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
|
||||
return 'http://localhost:3002/api';
|
||||
}
|
||||
|
||||
// Otherwise, use relative URL (same domain)
|
||||
return '/drones/api';
|
||||
};
|
||||
|
||||
const API_BASE_URL = getApiBaseUrl();
|
||||
|
||||
console.log('🔗 API Base URL:', API_BASE_URL);
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
|
||||
Reference in New Issue
Block a user