Fix Docker Config
This commit is contained in:
@@ -28,7 +28,8 @@ builder.Services.AddCors(options =>
|
|||||||
{
|
{
|
||||||
options.AddPolicy("AllowReactApp", builder =>
|
options.AddPolicy("AllowReactApp", builder =>
|
||||||
{
|
{
|
||||||
builder.WithOrigins("http://localhost:5173")
|
//builder.WithOrigins("http://localhost:5173")
|
||||||
|
builder.AllowAnyOrigin()
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowCredentials();
|
.AllowCredentials();
|
||||||
|
|||||||
@@ -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 {
|
server {
|
||||||
listen 80;
|
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/ {
|
location /api/ {
|
||||||
proxy_pass http://api_server;
|
proxy_pass http://titulares-api:8080/api/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
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)
|
# Pasa el resto de las peticiones al servicio del frontend
|
||||||
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
|
|
||||||
location / {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
proxy_pass http://titulares-frontend:80;
|
||||||
index index.html;
|
proxy_set_header Host $host;
|
||||||
# Esta línea es crucial para que el enrutamiento de React funcione correctamente (Single Page Application)
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
try_files $uri $uri/ /index.html;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import * as signalR from '@microsoft/signalr';
|
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
|
// Definimos un tipo para el estado de la conexión para más claridad
|
||||||
export type ConnectionStatus = 'Connecting' | 'Connected' | 'Disconnected' | 'Reconnecting';
|
export type ConnectionStatus = 'Connecting' | 'Connected' | 'Disconnected' | 'Reconnecting';
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import type { Configuracion, Titular } from '../types';
|
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({
|
const apiClient = axios.create({
|
||||||
baseURL: API_URL,
|
baseURL: API_URL,
|
||||||
|
|||||||
Reference in New Issue
Block a user