diff --git a/backend/src/gps/traccar-client.service.ts b/backend/src/gps/traccar-client.service.ts index b864162..68515db 100644 --- a/backend/src/gps/traccar-client.service.ts +++ b/backend/src/gps/traccar-client.service.ts @@ -300,18 +300,19 @@ export class TraccarClientService implements OnModuleInit { /** * Get the device port URL for mobile app configuration + * Returns hostname:port for Traccar Client app to connect to */ getDeviceServerUrl(): string { - // In production, this should be the public URL const port = this.configService.get('TRACCAR_DEVICE_PORT') || '5055'; - const frontendUrl = this.configService.get('FRONTEND_URL') || 'http://localhost:5173'; - // Extract hostname from frontend URL + // Use the Traccar public URL to derive the device server hostname + const traccarUrl = this.getTraccarUrl(); try { - const url = new URL(frontendUrl); - return `${url.protocol}//${url.hostname}:${port}`; + const url = new URL(traccarUrl); + // Return just hostname:port (no protocol - the app handles that) + return `${url.hostname}:${port}`; } catch { - return `http://localhost:${port}`; + return `localhost:${port}`; } }