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 dockerfile: Dockerfile.development # Use the existing development Dockerfile
args: args:
- NODE_ENV=development - NODE_ENV=development
- VITE_API_URL=http://localhost:${GATEWAY_PORT:-8000}
image: bakery/dashboard:${IMAGE_TAG:-latest} image: bakery/dashboard:${IMAGE_TAG:-latest}
container_name: bakery-dashboard container_name: bakery-dashboard
restart: unless-stopped restart: unless-stopped
environment: environment:
- NODE_ENV=development - NODE_ENV=development
- VITE_API_URL=http://localhost:${GATEWAY_PORT:-8000}
- VITE_APP_TITLE=PanIA Dashboard - VITE_APP_TITLE=PanIA Dashboard
- VITE_APP_VERSION=1.0.0 - VITE_APP_VERSION=1.0.0
ports: ports:

View File

@@ -27,6 +27,24 @@ export class ApiClient {
constructor(baseURL?: string) { constructor(baseURL?: string) {
this.baseURL = baseURL || apiConfig.baseURL; 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,9 +207,16 @@ export class ApiClient {
*/ */
async request<T = any>(endpoint: string, config: RequestConfig = {}): Promise<T> { async request<T = any>(endpoint: string, config: RequestConfig = {}): Promise<T> {
const startTime = Date.now(); const startTime = Date.now();
const url = `${this.baseURL}${endpoint}`; const url = this.buildURL(endpoint);
const method = config.method || 'GET'; const method = config.method || 'GET';
console.log('🚀 Making API request:', {
method,
endpoint,
url,
config
});
// Apply request interceptors // Apply request interceptors
const modifiedConfig = await this.applyRequestInterceptors(config); const modifiedConfig = await this.applyRequestInterceptors(config);
@@ -486,4 +511,5 @@ export class ApiClient {
} }
// Default API client instance // Default API client instance
console.log('🔧 Creating default API client...');
export const apiClient = new ApiClient(); export const apiClient = new ApiClient();