From 256f0b768407eefa94274a501b0ed49799cdc428 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Tue, 17 Dec 2024 01:19:00 +0100 Subject: [PATCH] Gestion nom de domaine websocket --- client/utils/socket.ts | 2 +- server/.env.example | 1 + server/src/geolocations/geolocations.gateway.ts | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/utils/socket.ts b/client/utils/socket.ts index 1c83d73..ab67f6f 100644 --- a/client/utils/socket.ts +++ b/client/utils/socket.ts @@ -1,5 +1,5 @@ import { io } from 'socket.io-client' -export const socket = io("http://192.168.1.198:3000", { +export const socket = io(process.env.EXPO_PUBLIC_TRAINTRAPE_MOI_SERVER, { reconnection: true, }) diff --git a/server/.env.example b/server/.env.example index 89bc53a..19bcfcb 100644 --- a/server/.env.example +++ b/server/.env.example @@ -1,3 +1,4 @@ DATABASE_URL="postgres://username:password@localhost:5432/traintrape-moi" JWT_SECRET="CHANGE_ME" API_GLOBAL_PREFIX="api" +API_HOSTNAME="traintrape-moi.luemy.eu" diff --git a/server/src/geolocations/geolocations.gateway.ts b/server/src/geolocations/geolocations.gateway.ts index 4e0d065..06fc795 100644 --- a/server/src/geolocations/geolocations.gateway.ts +++ b/server/src/geolocations/geolocations.gateway.ts @@ -1,7 +1,9 @@ import { SubscribeMessage, WebSocketGateway, WebSocketServer } from '@nestjs/websockets' import { Server, Socket } from 'socket.io' -@WebSocketGateway() +@WebSocketGateway({ + cors: { allowedHeaders: process.env.API_HOSTNAME }, +}) export class GeolocationsGateway { @WebSocketServer() server: Server