From 28a924bf0f01c80bd8feb02ad97be8e5c2fae4ad Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 1 Nov 2024 08:26:13 +0530 Subject: [PATCH] refactor: use apiUrl --- src/pages/Login.tsx | 3 ++- src/pages/MainPage.tsx | 3 ++- src/pages/Register.tsx | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index bab32c2f..4e4a1013 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -10,6 +10,7 @@ import { CircularProgress, } from '@mui/material'; import { useGlobalInfoStore } from "../context/globalInfo"; +import { apiUrl } from "../apiConfig"; const Login = () => { const [form, setForm] = useState({ @@ -40,7 +41,7 @@ const Login = () => { e.preventDefault(); setLoading(true); try { - const { data } = await axios.post(`http://localhost:8080/auth/login`, { email, password }); + const { data } = await axios.post(`${apiUrl}/auth/login`, { email, password }); dispatch({ type: 'LOGIN', payload: data }); notify('success', 'Welcome to Maxun!'); window.localStorage.setItem('user', JSON.stringify(data)); diff --git a/src/pages/MainPage.tsx b/src/pages/MainPage.tsx index adf92f1f..6ce7efe8 100644 --- a/src/pages/MainPage.tsx +++ b/src/pages/MainPage.tsx @@ -13,6 +13,7 @@ import { RunSettings } from "../components/molecules/RunSettings"; import { ScheduleSettings } from "../components/molecules/ScheduleSettings"; import { IntegrationSettings } from "../components/molecules/IntegrationSettings"; import { RobotSettings } from "../components/molecules/RobotSettings"; +import { apiUrl } from "../apiConfig"; interface MainPageProps { handleEditRecording: (id: string, fileName: string) => void; @@ -88,7 +89,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => { createRunForStoredRecording(runningRecordingId, settings).then(({ browserId, runId }: CreateRunResponse) => { setIds({ browserId, runId }); const socket = - io(`http://localhost:8080/${browserId}`, { + io(`${apiUrl}/${browserId}`, { transports: ["websocket"], rejectUnauthorized: false }); diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index 91915b70..8c92fe7b 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -4,6 +4,7 @@ import axios from 'axios'; import { AuthContext } from '../context/auth'; import { TextField, Button, CircularProgress, Typography, Box, Container } from '@mui/material'; import { useGlobalInfoStore } from "../context/globalInfo"; +import { apiUrl } from "../apiConfig"; const Register = () => { const [form, setForm] = useState({ @@ -31,7 +32,7 @@ const Register = () => { e.preventDefault(); setLoading(true); try { - const { data } = await axios.post('http://localhost:8080/auth/register', { + const { data } = await axios.post(`${apiUrl}/auth/register`, { email, password, });