Fix new Frontend 5

This commit is contained in:
Urtzi Alfaro
2025-08-03 21:03:41 +02:00
parent 2b358e2a7a
commit 77ccd486e9
2 changed files with 29 additions and 5 deletions

View File

@@ -591,13 +591,11 @@ services:
dockerfile: Dockerfile.development # Use the existing development Dockerfile
args:
- NODE_ENV=development
- VITE_API_URL=http://localhost:${GATEWAY_PORT:-8000}
image: bakery/dashboard:${IMAGE_TAG:-latest}
container_name: bakery-dashboard
restart: unless-stopped
environment:
- NODE_ENV=development
- VITE_API_URL=http://localhost:${GATEWAY_PORT:-8000}
- VITE_APP_TITLE=PanIA Dashboard
- VITE_APP_VERSION=1.0.0
ports:

View File

@@ -25,8 +25,26 @@ export class ApiClient {
private responseInterceptors: ResponseInterceptor[] = [];
private metrics: RequestMetrics[] = [];
constructor(baseURL?: string) {
this.baseURL = baseURL || apiConfig.baseURL;
constructor(baseURL?: string) {
this.baseURL = baseURL || apiConfig.baseURL;
// ✅ CRITICAL FIX: Remove trailing slash
this.baseURL = this.baseURL.replace(/\/+$/, '');
console.log('🔧 API Client initialized with baseURL:', this.baseURL);
}
private buildURL(endpoint: string): string {
// Remove leading slash from endpoint if present to avoid double slashes
const cleanEndpoint = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
const fullURL = `${this.baseURL}${cleanEndpoint}`;
// ✅ DEBUG: Log URL construction
console.log('🔗 Building URL:', {
baseURL: this.baseURL,
endpoint: cleanEndpoint,
fullURL: fullURL
});
return fullURL;
}
/**
@@ -189,8 +207,15 @@ export class ApiClient {
*/
async request<T = any>(endpoint: string, config: RequestConfig = {}): Promise<T> {
const startTime = Date.now();
const url = `${this.baseURL}${endpoint}`;
const url = this.buildURL(endpoint);
const method = config.method || 'GET';
console.log('🚀 Making API request:', {
method,
endpoint,
url,
config
});
// Apply request interceptors
const modifiedConfig = await this.applyRequestInterceptors(config);
@@ -486,4 +511,5 @@ export class ApiClient {
}
// Default API client instance
console.log('🔧 Creating default API client...');
export const apiClient = new ApiClient();