diff --git a/src/pages/pegase/home/components/studyService.ts b/src/pages/pegase/home/components/studyService.ts index 2b583a2..3ef2773 100644 --- a/src/pages/pegase/home/components/studyService.ts +++ b/src/pages/pegase/home/components/studyService.ts @@ -5,6 +5,7 @@ */ import { notifyToast } from '@/shared/notification/notification'; +import { getEnvVariables } from '@/envVariables'; interface StudyData { name: string; @@ -14,10 +15,11 @@ interface StudyData { horizon: string; trajectoryIds: number[]; } +const BASE_URL = getEnvVariables('VITE_BACK_END_BASE_URL'); export const saveStudy = async (studyData: StudyData, toggleModal: () => void) => { try { - const response = await fetch('http://localhost:8093/v1/study', { + const response = await fetch(`${BASE_URL}/v1/study`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -42,7 +44,7 @@ export const saveStudy = async (studyData: StudyData, toggleModal: () => void) = } }; export const fetchSuggestedKeywords = async (query: string): Promise => { - const response = await fetch(`http://localhost:8093/v1/study/keywords/search?partialName=${query}`); + const response = await fetch(`${BASE_URL}/v1/study/keywords/search?partialName=${query}`); if (!response.ok) { throw new Error('Failed to fetch suggested keywords'); } @@ -52,7 +54,7 @@ export const fetchSuggestedKeywords = async (query: string): Promise = export const handleDelete = async (id: number) => { try { - const response = await fetch(`http://localhost:8093/v1/study/${id}`, { + const response = await fetch(`${BASE_URL}/v1/study/${id}`, { method: 'DELETE', }); if (!response.ok) { diff --git a/src/pages/pegase/studies/ProjectInput.tsx b/src/pages/pegase/studies/ProjectInput.tsx index 2af0017..f5c52ff 100644 --- a/src/pages/pegase/studies/ProjectInput.tsx +++ b/src/pages/pegase/studies/ProjectInput.tsx @@ -7,14 +7,16 @@ // src/components/ProjectInput.tsx import React, { useState, useEffect } from 'react'; import { RdsInputText } from 'rte-design-system-react'; +import { getEnvVariables } from '@/envVariables'; interface ProjectManagerProps { value: string; onChange: (value: string) => void; } +const BASE_URL = getEnvVariables('VITE_BACK_END_BASE_URL'); const fetchProjects = async (query: string): Promise => { - const response = await fetch(`http://localhost:8093/v1/project/autocomplete?partialName=${query}`); + const response = await fetch(`${BASE_URL}/v1/project/autocomplete?partialName=${query}`); if (!response.ok) { throw new Error('Failed to fetch projects'); }