Try 1550
This commit is contained in:
1
frontend/.env
Normal file
1
frontend/.env
Normal file
@@ -0,0 +1 @@
|
||||
VITE_API_BASE_URL=http://192.168.5.128:8905
|
||||
@@ -1,21 +1,37 @@
|
||||
# /frontend/proxy/nginx.conf
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# Pasa todas las peticiones a la API al servicio del backend
|
||||
location /api/ {
|
||||
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;
|
||||
}
|
||||
|
||||
# Pasa el resto de las peticiones al servicio del frontend
|
||||
location / {
|
||||
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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://titulares-api:8080;
|
||||
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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
}
|
||||
|
||||
location /titularesHub/ {
|
||||
proxy_pass http://titulares-api:8080;
|
||||
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;
|
||||
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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,10 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import * as signalR from '@microsoft/signalr';
|
||||
|
||||
// Construye la URL completa del Hub
|
||||
const HUB_URL = `${import.meta.env.VITE_API_BASE_URL}/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';
|
||||
|
||||
@@ -4,7 +4,7 @@ import axios from 'axios';
|
||||
import type { Configuracion, Titular } from '../types';
|
||||
|
||||
//const API_URL = 'http://localhost:5174/api';
|
||||
const API_URL = '/api';
|
||||
const API_URL = `${import.meta.env.VITE_API_BASE_URL}/api`;
|
||||
|
||||
const apiClient = axios.create({
|
||||
baseURL: API_URL,
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vite.dev/config/
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
server: {
|
||||
proxy: {
|
||||
// Redirige cualquier petición que empiece con '/api' al backend
|
||||
'/api': {
|
||||
target: 'http://localhost:5174', // <-- Usa el puerto HTTP del backend
|
||||
changeOrigin: true,
|
||||
},
|
||||
// Redirige cualquier petición a '/titularesHub' al backend (para SignalR)
|
||||
'/titularesHub': {
|
||||
target: 'http://localhost:5174', // <-- Usa el mismo puerto
|
||||
ws: true, // <-- Habilita el proxy para WebSockets (crucial para SignalR)
|
||||
changeOrigin: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user