Fix jwt-token
This commit is contained in:
@@ -1,9 +1,24 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const API_BASE_URL = import.meta.env.VITE_API_URL ||
|
// Determine API base URL based on environment
|
||||||
(process.env.NODE_ENV === 'production'
|
const getApiBaseUrl = () => {
|
||||||
? '/drones/api'
|
// If VITE_API_URL is explicitly set, use it
|
||||||
: 'http://localhost:3002/api');
|
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({
|
const api = axios.create({
|
||||||
baseURL: API_BASE_URL,
|
baseURL: API_BASE_URL,
|
||||||
|
|||||||
Reference in New Issue
Block a user