diff --git a/smartassist/src/frontend.js b/smartassist/src/frontend.js index 22a336d..92c6c28 100644 --- a/smartassist/src/frontend.js +++ b/smartassist/src/frontend.js @@ -3,6 +3,12 @@ const chatbox = document.getElementById('chatbox'); const userInput = document.getElementById('userInput'); +// Get API endpoint for chat from environment variable +const apiEndpoint = process.env.BE_API_ENDPOINT || 'http://localhost:5005/api/chat'; // Default if not found +console.log("The API Endpoint is:", apiEndpoint); + + + // Define a function to send the user's message to the AI function sendMessage() { // Get the user's input message and trim any whitespace @@ -11,7 +17,8 @@ function sendMessage() { // Check if the message is not empty if (query !== '') { // Send a POST request to the /api/chat endpoint with the message - fetch('http://localhost:5005/api/chat', { + // fetch('http://localhost:5005/api/chat', { + fetch(apiEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query }),