feat: introduce backend url environment variable

ref: N25B-352
This commit is contained in:
Twirre Meulenbelt
2026-01-29 17:40:49 +01:00
parent 378a64c7ca
commit 4395e44dbf
15 changed files with 65 additions and 23 deletions

View File

@@ -2,6 +2,7 @@
// University within the Software Project course.
// © Copyright Utrecht University (Department of Information and Computing Sciences)
import { useEffect, useState } from 'react'
import { API_BASE_URL } from '../../config/api.ts';
/**
* Displays the current connection status of a robot in real time.
@@ -25,7 +26,7 @@ export default function ConnectedRobots() {
useEffect(() => {
// Open a Server-Sent Events (SSE) connection to receive live ping updates.
// We're expecting a stream of data like that looks like this: `data = False` or `data = True`
const eventSource = new EventSource("http://localhost:8000/robot/ping_stream");
const eventSource = new EventSource(`${API_BASE_URL}/robot/ping_stream`);
eventSource.onmessage = (event) => {
// Expecting messages in JSON format: `true` or `false`