arreglar localhost
This commit is contained in:
@@ -28,6 +28,9 @@ services:
|
||||
restart: always
|
||||
ports:
|
||||
- "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:
|
||||
- gateway
|
||||
networks:
|
||||
|
||||
@@ -9,5 +9,8 @@ RUN npm run build
|
||||
# Production stage
|
||||
FROM nginx:alpine
|
||||
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
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
12
manager/docker-entrypoint.sh
Executable file
12
manager/docker-entrypoint.sh
Executable 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 "$@"
|
||||
@@ -1,12 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>WhatsApp Gateway Manager</title>
|
||||
</head>
|
||||
<body>
|
||||
</head>
|
||||
<body>
|
||||
<script src="/config.js"></script>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
4
manager/public/config.js
Normal file
4
manager/public/config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
window.APP_CONFIG = {
|
||||
VITE_API_URL: "http://localhost:3001",
|
||||
VITE_WS_URL: "ws://localhost:3003"
|
||||
};
|
||||
@@ -9,7 +9,7 @@ export const Dashboard: React.FC = () => {
|
||||
const [isConnected, setIsConnected] = useState(false);
|
||||
|
||||
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);
|
||||
setWsService(service);
|
||||
|
||||
@@ -34,7 +34,7 @@ export const Dashboard: React.FC = () => {
|
||||
|
||||
const fetchGatewayStatus = async () => {
|
||||
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`);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
|
||||
7
manager/src/vite-env.d.ts
vendored
7
manager/src/vite-env.d.ts
vendored
@@ -1 +1,8 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface Window {
|
||||
APP_CONFIG?: {
|
||||
VITE_API_URL: string;
|
||||
VITE_WS_URL: string;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user