diff --git a/backend/src/Titulares.Api/Program.cs b/backend/src/Titulares.Api/Program.cs index dfbd62c..560ab0c 100644 --- a/backend/src/Titulares.Api/Program.cs +++ b/backend/src/Titulares.Api/Program.cs @@ -28,7 +28,8 @@ builder.Services.AddCors(options => { options.AddPolicy("AllowReactApp", builder => { - builder.WithOrigins("http://localhost:5173") + //builder.WithOrigins("http://localhost:5173") + builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); diff --git a/frontend/proxy/nginx.conf b/frontend/proxy/nginx.conf index 6b309cf..bcd0459 100644 --- a/frontend/proxy/nginx.conf +++ b/frontend/proxy/nginx.conf @@ -1,40 +1,21 @@ -# Define el servidor upstream para la API, usando el nombre del servicio de Docker Compose -upstream api_server { - server titulares-api:8080; -} - server { listen 80; - # Redirigir todas las peticiones que comiencen con /api/ al servicio del backend + # Pasa todas las peticiones a la API al servicio del backend location /api/ { - proxy_pass http://api_server; + proxy_pass http://titulares-api:8080/api/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - - # Cabeceras importantes para SignalR (WebSockets) - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; } - # Redirigir todas las peticiones que comiencen con /titularesHub (para SignalR) - location /titularesHub { - proxy_pass http://api_server; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - } - - # Servir los archivos del frontend para todas las demás peticiones + # Pasa el resto de las peticiones al servicio del frontend location / { - root /usr/share/nginx/html; - index index.html; - # Esta línea es crucial para que el enrutamiento de React funcione correctamente (Single Page Application) - try_files $uri $uri/ /index.html; + proxy_pass http://titulares-frontend:80; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } } \ No newline at end of file diff --git a/frontend/src/hooks/useSignalR.ts b/frontend/src/hooks/useSignalR.ts index e23f901..e81d889 100644 --- a/frontend/src/hooks/useSignalR.ts +++ b/frontend/src/hooks/useSignalR.ts @@ -3,7 +3,8 @@ import { useEffect, useRef, useState } from 'react'; import * as signalR from '@microsoft/signalr'; -const HUB_URL = 'http://localhost:5174/titularesHub'; +//const HUB_URL = 'http://localhost:5174/titularesHub'; +const HUB_URL = '/titularesHub'; // Definimos un tipo para el estado de la conexión para más claridad export type ConnectionStatus = 'Connecting' | 'Connected' | 'Disconnected' | 'Reconnecting'; diff --git a/frontend/src/services/apiService.ts b/frontend/src/services/apiService.ts index 07c56e2..554fd0b 100644 --- a/frontend/src/services/apiService.ts +++ b/frontend/src/services/apiService.ts @@ -3,7 +3,8 @@ import axios from 'axios'; import type { Configuracion, Titular } from '../types'; -const API_URL = 'http://localhost:5174/api'; +//const API_URL = 'http://localhost:5174/api'; +const API_URL = '/api'; const apiClient = axios.create({ baseURL: API_URL,