From 16f2ac7cad17aede60ff936b1cd92d9490ecf38a Mon Sep 17 00:00:00 2001 From: Kabir <44284877+kabir0x23@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:34:44 +0530 Subject: [PATCH] performance (#902) --- src/components/Resources/Hackliner/Hackliner.jsx | 3 ++- src/components/Resources/ResourcesElements.jsx | 3 ++- src/components/Tools/SubdomainFinder/SubdomainFinder.jsx | 3 ++- src/components/WebSecurity/WebSecurityTopics/Topic.jsx | 5 +++-- src/components/WebSecurity/WebSecurityTopics/Topics.jsx | 3 ++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/Resources/Hackliner/Hackliner.jsx b/src/components/Resources/Hackliner/Hackliner.jsx index c5181c5a..27302659 100644 --- a/src/components/Resources/Hackliner/Hackliner.jsx +++ b/src/components/Resources/Hackliner/Hackliner.jsx @@ -12,6 +12,7 @@ import { } from "src/components/Resources/Hacklist/HacklistElements.jsx"; import { CodeBlock } from "src/components/Resources/Hacklist/Hacklist.jsx"; import { useParams } from "react-router-dom"; +import { getApiUrl } from "src/features/apiUrl.js"; const Hackliners = () => { const { title } = useParams(); @@ -22,7 +23,7 @@ const Hackliners = () => { useEffect(() => { const fetchData = async () => { try { - const response = await axios.get(`http://localhost:5000/api/resources/${title}`); + const response = await axios.get(getApiUrl(`/api/resources/${title}`)); setData(response?.data); console.log("Fetched data:", response?.data); } catch (error) { diff --git a/src/components/Resources/ResourcesElements.jsx b/src/components/Resources/ResourcesElements.jsx index 660f2e72..96918554 100644 --- a/src/components/Resources/ResourcesElements.jsx +++ b/src/components/Resources/ResourcesElements.jsx @@ -13,6 +13,7 @@ import { } from "src/components/Resources/Hacklist/HacklistElements.jsx"; import { CodeBlock } from "src/components/Resources/Hacklist/Hacklist.jsx"; import { useParams } from "react-router-dom"; +import { getApiUrl } from "src/features/apiUrl.js"; const Hackliners = () => { const { title } = useParams(); @@ -23,7 +24,7 @@ const Hackliners = () => { useEffect(() => { const fetchData = async () => { try { - const response = await axios.get(`http://localhost:5000/api/resources/${title}`); + const response = await axios.get(getApiUrl(`/api/resources/${title}`)); setData(response?.data); } catch (error) { setError(error); diff --git a/src/components/Tools/SubdomainFinder/SubdomainFinder.jsx b/src/components/Tools/SubdomainFinder/SubdomainFinder.jsx index da420063..b1ee6ccf 100644 --- a/src/components/Tools/SubdomainFinder/SubdomainFinder.jsx +++ b/src/components/Tools/SubdomainFinder/SubdomainFinder.jsx @@ -18,6 +18,7 @@ import { CircleSpinner } from "react-spinners-kit"; import apiStatus from "src/features/apiStatus"; import UnderMaintenance from "src/components/Other/UnderMaintenance/UnderMaintenance"; import { RiEarthFill } from "react-icons/ri"; +import { getApiUrl } from "src/features/apiUrl.js"; const SubdomainFinder = () => { const { isApiLoading, isApiWorking } = apiStatus(); @@ -41,7 +42,7 @@ const SubdomainFinder = () => { return; } try { - const response = await axios.get(`http://localhost:5000/api/subdomains?domain=${domainName}`); + const response = await axios.get(getApiUrl(`/api/subdomains?domain=${domainName}`)); setSubdomains(response?.data?.subdomains); setIsLoading(false); } catch (error) { diff --git a/src/components/WebSecurity/WebSecurityTopics/Topic.jsx b/src/components/WebSecurity/WebSecurityTopics/Topic.jsx index 6f836e46..d82ad773 100644 --- a/src/components/WebSecurity/WebSecurityTopics/Topic.jsx +++ b/src/components/WebSecurity/WebSecurityTopics/Topic.jsx @@ -4,6 +4,7 @@ import { Container } from "./TopicElements"; import Sidebar from "src/components/WebSecurity/Sidebar"; import SubTopic from "./SubTopic"; import axios from "axios"; +import { getApiUrl } from "src/features/apiUrl.js"; const Topic = () => { const { id } = useParams(); @@ -16,10 +17,10 @@ const Topic = () => { const fetchData = async () => { setLoading(true); try { - const topicsResponse = await axios.get("http://localhost:5000/api/topics/sidebar"); + const topicsResponse = await axios.get(getApiUrl("/api/topics/sidebar")); setTopics(topicsResponse.data); - const topicResponse = await axios.get(`http://localhost:5000/api/topics/${id}`); + const topicResponse = await axios.get(getApiUrl(`/api/topics/${id}`)); setTopic(topicResponse.data); setLoading(false); // Stops loading after both requests complete diff --git a/src/components/WebSecurity/WebSecurityTopics/Topics.jsx b/src/components/WebSecurity/WebSecurityTopics/Topics.jsx index e7609743..86b5cc23 100644 --- a/src/components/WebSecurity/WebSecurityTopics/Topics.jsx +++ b/src/components/WebSecurity/WebSecurityTopics/Topics.jsx @@ -14,6 +14,7 @@ import { TopicsContainer, Container, } from "src/components/WebSecurity/WebSecurityTopics/TopicElements.jsx"; +import { getApiUrl } from "src/features/apiUrl.js"; const Topics = () => { const [topics, setTopics] = useState([]); @@ -24,7 +25,7 @@ const Topics = () => { // Fetch data from the API const fetchData = async () => { try { - const response = await axios.get("http://localhost:5000/api/topics"); + const response = await axios.get(getApiUrl("/api/topics")); setTopics(response.data); // Update state with the fetched data setLoading(false); // Stop loading when data is received } catch (err) {