arreglar localhost

This commit is contained in:
2026-01-17 22:24:56 -06:00
parent 64327ef5df
commit 153bdf2819
7 changed files with 43 additions and 13 deletions

View File

@@ -28,6 +28,9 @@ services:
restart: always restart: always
ports: ports:
- "3002:80" # Web Interface - "3002:80" # Web Interface
environment:
- VITE_API_URL=${VITE_API_URL:-http://localhost:3001}
- VITE_WS_URL=${VITE_WS_URL:-ws://localhost:3003}
depends_on: depends_on:
- gateway - gateway
networks: networks:

View File

@@ -9,5 +9,8 @@ RUN npm run build
# Production stage # Production stage
FROM nginx:alpine FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html COPY --from=build /app/dist /usr/share/nginx/html
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 80 EXPOSE 80
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

12
manager/docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# Generate config.js
cat <<EOF > /usr/share/nginx/html/config.js
window.APP_CONFIG = {
VITE_API_URL: "${VITE_API_URL}",
VITE_WS_URL: "${VITE_WS_URL}"
};
EOF
# Exec the passed command
exec "$@"

View File

@@ -1,12 +1,13 @@
<!DOCTYPE html> <!doctype html>
<html lang="es"> <html lang="es">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WhatsApp Gateway Manager</title> <title>WhatsApp Gateway Manager</title>
</head> </head>
<body> <body>
<div id="root"></div> <script src="/config.js"></script>
<script type="module" src="/src/main.tsx"></script> <div id="root"></div>
</body> <script type="module" src="/src/main.tsx"></script>
</html> </body>
</html>

4
manager/public/config.js Normal file
View File

@@ -0,0 +1,4 @@
window.APP_CONFIG = {
VITE_API_URL: "http://localhost:3001",
VITE_WS_URL: "ws://localhost:3003"
};

View File

@@ -9,7 +9,7 @@ export const Dashboard: React.FC = () => {
const [isConnected, setIsConnected] = useState(false); const [isConnected, setIsConnected] = useState(false);
useEffect(() => { useEffect(() => {
const wsUrl = import.meta.env.VITE_WS_URL || 'ws://localhost:3003'; const wsUrl = window.APP_CONFIG?.VITE_WS_URL || import.meta.env.VITE_WS_URL || 'ws://localhost:3003';
const service = new WebSocketService(wsUrl); const service = new WebSocketService(wsUrl);
setWsService(service); setWsService(service);
@@ -34,7 +34,7 @@ export const Dashboard: React.FC = () => {
const fetchGatewayStatus = async () => { const fetchGatewayStatus = async () => {
try { try {
const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:3001'; const apiUrl = window.APP_CONFIG?.VITE_API_URL || import.meta.env.VITE_API_URL || 'http://localhost:3001';
const response = await fetch(`${apiUrl}/api/status`); const response = await fetch(`${apiUrl}/api/status`);
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();

View File

@@ -1 +1,8 @@
/// <reference types="vite/client" /> /// <reference types="vite/client" />
interface Window {
APP_CONFIG?: {
VITE_API_URL: string;
VITE_WS_URL: string;
};
}