diff --git a/src/api/auth.ts b/src/api/auth.ts index 34ebcab8..32a11f69 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -1,8 +1,9 @@ import { default as axios } from "axios"; +import { apiUrl } from "../apiConfig" export const getUserById = async (userId: string) => { try { - const response = await axios.get(`http://localhost:8080/auth/user/${userId}`); + const response = await axios.get(`${apiUrl}/auth/user/${userId}`); if (response.status === 200) { return response.data; } else { diff --git a/src/api/integration.ts b/src/api/integration.ts index 2804508b..d484abbb 100644 --- a/src/api/integration.ts +++ b/src/api/integration.ts @@ -1,8 +1,9 @@ import { default as axios } from "axios"; +import { apiUrl } from "../apiConfig"; export const handleUploadCredentials = async (fileName: string, credentials: any, spreadsheetId: string, range: string): Promise => { try { - const response = await axios.post('http://localhost:8080/integration/upload-credentials', { fileName, credentials: JSON.parse(credentials), spreadsheetId, range }); + const response = await axios.post(`${apiUrl}/integration/upload-credentials`, { fileName, credentials: JSON.parse(credentials), spreadsheetId, range }); if (response.status === 200) { return response.data; } else { diff --git a/src/api/proxy.ts b/src/api/proxy.ts index 4ca79742..e08dcfae 100644 --- a/src/api/proxy.ts +++ b/src/api/proxy.ts @@ -1,8 +1,9 @@ import { default as axios } from "axios"; +import { apiUrl } from "../apiConfig"; export const sendProxyConfig = async (proxyConfig: { server_url: string, username?: string, password?: string }): Promise => { try { - const response = await axios.post(`http://localhost:8080/proxy/config`, proxyConfig); + const response = await axios.post(`${apiUrl}/proxy/config`, proxyConfig); if (response.status === 200) { return response.data; } else { @@ -16,7 +17,7 @@ export const sendProxyConfig = async (proxyConfig: { server_url: string, usernam export const getProxyConfig = async (): Promise<{ proxy_url: string, auth: boolean }> => { try { - const response = await axios.get(`http://localhost:8080/proxy/config`); + const response = await axios.get(`${apiUrl}/proxy/config`); if (response.status === 200) { return response.data; } else { @@ -30,7 +31,7 @@ export const getProxyConfig = async (): Promise<{ proxy_url: string, auth: boole export const testProxyConfig = async (): Promise<{ success: boolean }> => { try { - const response = await axios.get(`http://localhost:8080/proxy/test`); + const response = await axios.get(`${apiUrl}/proxy/test`); if (response.status === 200) { return response.data; } else { @@ -44,7 +45,7 @@ export const testProxyConfig = async (): Promise<{ success: boolean }> => { export const deleteProxyConfig = async (): Promise => { try { - const response = await axios.delete(`http://localhost:8080/proxy/config`); + const response = await axios.delete(`${apiUrl}/proxy/config`); if (response.status === 200) { return response.data; } else { diff --git a/src/api/recording.ts b/src/api/recording.ts index ef51a476..6b816001 100644 --- a/src/api/recording.ts +++ b/src/api/recording.ts @@ -1,8 +1,9 @@ import { default as axios, AxiosResponse } from "axios"; +import { apiUrl } from "../apiConfig"; export const startRecording = async() : Promise => { try { - const response = await axios.get('http://localhost:8080/record/start') + const response = await axios.get(`${apiUrl}/record/start`) if (response.status === 200) { return response.data; } else { @@ -14,7 +15,7 @@ export const startRecording = async() : Promise => { }; export const stopRecording = async (id: string): Promise => { - await axios.get(`http://localhost:8080/record/stop/${id}`) + await axios.get(`${apiUrl}/record/stop/${id}`) .then((response : AxiosResponse) => { }) .catch((error: any) => { @@ -23,7 +24,7 @@ export const stopRecording = async (id: string): Promise => { export const getActiveBrowserId = async(): Promise => { try { - const response = await axios.get('http://localhost:8080/record/active'); + const response = await axios.get(`${apiUrl}/record/active`); if (response.status === 200) { return response.data; } else { @@ -36,7 +37,7 @@ export const getActiveBrowserId = async(): Promise => { export const interpretCurrentRecording = async(): Promise => { try { - const response = await axios.get('http://localhost:8080/record/interpret'); + const response = await axios.get(`${apiUrl}/record/interpret`); if (response.status === 200) { return true; } else { @@ -50,7 +51,7 @@ export const interpretCurrentRecording = async(): Promise => { export const stopCurrentInterpretation = async(): Promise => { try { - const response = await axios.get('http://localhost:8080/record/interpret/stop'); + const response = await axios.get(`${apiUrl}/record/interpret/stop`); if (response.status === 200) { return; } else { @@ -63,7 +64,7 @@ export const stopCurrentInterpretation = async(): Promise => { export const getCurrentUrl = async (): Promise => { try { - const response = await axios.get('http://localhost:8080/record/active/url'); + const response = await axios.get(`${apiUrl}/record/active/url`); if (response.status === 200) { return response.data; } else { @@ -77,7 +78,7 @@ export const getCurrentUrl = async (): Promise => { export const getCurrentTabs = async (): Promise => { try { - const response = await axios.get('http://localhost:8080/record/active/tabs'); + const response = await axios.get(`${apiUrl}/record/active/tabs`); if (response.status === 200) { return response.data; } else { diff --git a/src/api/storage.ts b/src/api/storage.ts index da017027..9b4b06b2 100644 --- a/src/api/storage.ts +++ b/src/api/storage.ts @@ -3,10 +3,11 @@ import { WorkflowFile } from "maxun-core"; import { RunSettings } from "../components/molecules/RunSettings"; import { ScheduleSettings } from "../components/molecules/ScheduleSettings"; import { CreateRunResponse, ScheduleRunResponse } from "../pages/MainPage"; +import { apiUrl } from "../apiConfig"; export const getStoredRecordings = async (): Promise => { try { - const response = await axios.get('http://localhost:8080/storage/recordings'); + const response = await axios.get(`${apiUrl}/storage/recordings`); if (response.status === 200) { return response.data; } else { @@ -20,7 +21,7 @@ export const getStoredRecordings = async (): Promise => { export const getStoredRuns = async (): Promise => { try { - const response = await axios.get('http://localhost:8080/storage/runs'); + const response = await axios.get(`${apiUrl}/storage/runs`); if (response.status === 200) { return response.data; } else { @@ -34,7 +35,7 @@ export const getStoredRuns = async (): Promise => { export const getStoredRecording = async (id: string) => { try { - const response = await axios.get(`http://localhost:8080/storage/recordings/${id}`); + const response = await axios.get(`${apiUrl}/storage/recordings/${id}`); if (response.status === 200) { return response.data; } else { @@ -48,7 +49,7 @@ export const getStoredRecording = async (id: string) => { export const deleteRecordingFromStorage = async (id: string): Promise => { try { - const response = await axios.delete(`http://localhost:8080/storage/recordings/${id}`); + const response = await axios.delete(`${apiUrl}/storage/recordings/${id}`); if (response.status === 200) { return response.data; } else { @@ -62,7 +63,7 @@ export const deleteRecordingFromStorage = async (id: string): Promise = export const deleteRunFromStorage = async (id: string): Promise => { try { - const response = await axios.delete(`http://localhost:8080/storage/runs/${id}`); + const response = await axios.delete(`${apiUrl}/storage/runs/${id}`); if (response.status === 200) { return response.data; } else { @@ -76,7 +77,7 @@ export const deleteRunFromStorage = async (id: string): Promise => { export const editRecordingFromStorage = async (browserId: string, id: string): Promise => { try { - const response = await axios.put(`http://localhost:8080/workflow/${browserId}/${id}`); + const response = await axios.put(`${apiUrl}/workflow/${browserId}/${id}`); if (response.status === 200) { return response.data; } else { @@ -91,7 +92,7 @@ export const editRecordingFromStorage = async (browserId: string, id: string): P export const createRunForStoredRecording = async (id: string, settings: RunSettings): Promise => { try { const response = await axios.put( - `http://localhost:8080/storage/runs/${id}`, + `${apiUrl}/storage/runs/${id}`, { ...settings }); if (response.status === 200) { return response.data; @@ -106,7 +107,7 @@ export const createRunForStoredRecording = async (id: string, settings: RunSetti export const interpretStoredRecording = async (id: string): Promise => { try { - const response = await axios.post(`http://localhost:8080/storage/runs/run/${id}`); + const response = await axios.post(`${apiUrl}/storage/runs/run/${id}`); if (response.status === 200) { return response.data; } else { @@ -120,7 +121,7 @@ export const interpretStoredRecording = async (id: string): Promise => export const notifyAboutAbort = async (id: string): Promise => { try { - const response = await axios.post(`http://localhost:8080/storage/runs/abort/${id}`); + const response = await axios.post(`${apiUrl}/storage/runs/abort/${id}`); if (response.status === 200) { return response.data; } else { @@ -135,7 +136,7 @@ export const notifyAboutAbort = async (id: string): Promise => { export const scheduleStoredRecording = async (id: string, settings: ScheduleSettings): Promise => { try { const response = await axios.put( - `http://localhost:8080/storage/schedule/${id}`, + `${apiUrl}/storage/schedule/${id}`, { ...settings }); if (response.status === 200) { return response.data; @@ -150,7 +151,7 @@ export const scheduleStoredRecording = async (id: string, settings: ScheduleSett export const getSchedule = async (id: string) => { try { - const response = await axios.get(`http://localhost:8080/storage/schedule/${id}`); + const response = await axios.get(`${apiUrl}/storage/schedule/${id}`); if (response.status === 200) { return response.data.schedule; } else { @@ -164,7 +165,7 @@ export const getSchedule = async (id: string) => { export const deleteSchedule = async (id: string): Promise => { try { - const response = await axios.delete(`http://localhost:8080/storage/schedule/${id}`); + const response = await axios.delete(`${apiUrl}/storage/schedule/${id}`); if (response.status === 200) { return response.data; } else { diff --git a/src/api/workflow.ts b/src/api/workflow.ts index a32b6cbc..03b677b1 100644 --- a/src/api/workflow.ts +++ b/src/api/workflow.ts @@ -1,10 +1,11 @@ import { WhereWhatPair, WorkflowFile } from "maxun-core"; import { emptyWorkflow } from "../shared/constants"; import { default as axios, AxiosResponse } from "axios"; +import { apiUrl } from "../apiConfig"; export const getActiveWorkflow = async(id: string) : Promise => { try { - const response = await axios.get(`http://localhost:8080/workflow/${id}`) + const response = await axios.get(`${apiUrl}/workflow/${id}`) if (response.status === 200) { return response.data; } else { @@ -18,7 +19,7 @@ export const getActiveWorkflow = async(id: string) : Promise => { export const getParamsOfActiveWorkflow = async(id: string) : Promise => { try { - const response = await axios.get(`http://localhost:8080/workflow/params/${id}`) + const response = await axios.get(`${apiUrl}/workflow/params/${id}`) if (response.status === 200) { return response.data; } else { @@ -32,7 +33,7 @@ export const getParamsOfActiveWorkflow = async(id: string) : Promise => { try { - const response = await axios.delete(`http://localhost:8080/workflow/pair/${index}`); + const response = await axios.delete(`${apiUrl}/workflow/pair/${index}`); if (response.status === 200) { return response.data; } else { @@ -46,7 +47,7 @@ export const deletePair = async(index: number): Promise => { export const AddPair = async(index: number, pair: WhereWhatPair): Promise => { try { - const response = await axios.post(`http://localhost:8080/workflow/pair/${index}`, { + const response = await axios.post(`${apiUrl}/workflow/pair/${index}`, { pair, }, {headers: {'Content-Type': 'application/json'}}); if (response.status === 200) { @@ -62,7 +63,7 @@ export const AddPair = async(index: number, pair: WhereWhatPair): Promise => { try { - const response = await axios.put(`http://localhost:8080/workflow/pair/${index}`, { + const response = await axios.put(`${apiUrl}/workflow/pair/${index}`, { pair, }, {headers: {'Content-Type': 'application/json'}}); if (response.status === 200) {