From 70c28e0cf2cb2674cfd0d08f3e0bac489c130480 Mon Sep 17 00:00:00 2001 From: yogiedigital Date: Sat, 20 Sep 2025 01:57:50 +0700 Subject: [PATCH] add env port --- env.example | 3 ++- src/App.jsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/env.example b/env.example index 3f62998..0803a39 100644 --- a/env.example +++ b/env.example @@ -2,4 +2,5 @@ VITE_API_URL=https://api.example.com VITE_APP_NAME=MyReactApp VITE_MQTT_SERVER=mosquitto-apotek-2 # VITE_MQTT_SERVER=117.102.231.130 -VITE_MQTT_PORT=4001 \ No newline at end of file +VITE_MQTT_PORT=4001 +VITE_MQTT_PROTOCOL=mqtt \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index bcf6327..3723c7d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -42,7 +42,8 @@ function App() { const connectToMqtt = () => { try { - const connectUrl = `mqtt://${mqttOptions.host}:${mqttOptions.port}`; + // const connectUrl = `mqtt://${mqttOptions.host}:${mqttOptions.port}`; + const connectUrl = `${import.meta.env.VITE_MQTT_PROTOCOL}://${mqttOptions.host}:${mqttOptions.port}`; console.log('Attempting to connect to:', connectUrl); mqttClient = mqtt.connect(connectUrl, {