API calls in my React application unexpectedly stop after a while

I’m facing an unexpected issue with my React application. Initially, the application works fine, but after a while, API calls unexpectedly stop.

To provide more information about the issue, in my application, we facilitate data exchange between users, and for that purpose, we make a series of API calls. However, after a certain period of time, the API calls abruptly halt, and I receive no response. This significantly affects the user experience and undermines the reliability of the application.

What steps can I take to understand why the API calls are stopping, or does anyone have experience with a similar issue?

Thank you.

my app.jsx file


const HomePage = lazy(() => import("./pages/HomePage"));
const MainPage = lazy(() => import("./pages/MainPage"));
const UserProfile = lazy(() => import("./pages/UserProfilePage"));
const SpesificUserProfile = lazy(() => import("./pages/SpesificUserProfile"));
import { Routes, Route } from "react-router-dom";
import "./index.css";
import "bootstrap/dist/css/bootstrap.min.css";
import "react-toastify/dist/ReactToastify.css";
const MessagesPage = lazy(() => import("./pages/MessagesPage"));
const ChatDetailsPage = lazy(() => import("./pages/ChatDetailsPage"));
const PostDetailPage = lazy(() => import("./pages/PostDetailPage"));
const FollowingDetailPage = lazy(() => import("./pages/FollowingDetail"));
const FollowerDetailPage = lazy(() => import("./pages/FollowersDetailPage"));
const ImagePostDetailPage = lazy(() => import("./pages/ImagePostDetailPage"));
const DeactivatedPage = lazy(() => import("./pages/DeactivatedPage"));
const NotificationsPage = lazy(() => import("./pages/NotificationsPage"));
const Posts = lazy(() => import("./components/Posts/Posts"));

import { ThemeContext } from "./context/ThemeContext";
import { UserProvider } from "./context/UserContext";

import LoadingSpinner from "./components/ui/LoadingSpinner";

function App() {
  const [
    { theme, themeName, activeFontSizeOption },
    toggleThemeBetweenLightDarkMode,
  ] = useContext(ThemeContext);

  return (
    <UserProvider>
      <div
        className={
          themeName === "dark-theme"
            ? "dark-theme"
            : themeName === "light-theme"
            ? "light-theme"
            : null
        }
        style={{
          backgroundColor: theme.backgroundColor,
          color: theme.color,
        }}
      >
        <Suspense
          fallback={
            <LoadingSpinner
              isSuspense={true}
              strokeColor={"rgb(29, 155, 240)"}
            ></LoadingSpinner>
          }
        >
          <Routes>
            <Route path="/" element={<HomePage />} />

            <Route path="/home" element={<MainPage />}></Route>

            <Route
              path="/notifications"
              element={<NotificationsPage />}
            ></Route>
            <Route path="/messages" element={<MessagesPage />}></Route>
            <Route path="/profile" element={<UserProfile />}></Route>
            <Route
              path="/profile/:id"
              element={<SpesificUserProfile />}
            ></Route>
            <Route
              path="/:postOwner/status/:postId"
              element={<PostDetailPage />}
            ></Route>
            <Route
              path="/messages/:chatRoomId"
              element={<ChatDetailsPage />}
            ></Route>
            {/* new page start to check  INFO => CONTROL STYLING*/}
            <Route
              path="/:postOwner/status/:postId/photo/1"
              element={<ImagePostDetailPage />}
            ></Route>
            {/* new page finish to check INFO => CONTROL STYLING */}
            <Route
              path="/profile/:userId/following"
              element={<FollowingDetailPage />}
            ></Route>

            <Route
              path="/profile/:userId/followers"
              element={<FollowerDetailPage />}
            ></Route>

            <Route
              path="/settings/deactivated"
              element={<DeactivatedPage />}
            ></Route>

            {/* test pages start to check  */}
            <Route path="/posts-component-test" element={<Posts />}></Route>

            {/* test pages finish to check  */}
          </Routes>
        </Suspense>
      </div>
    </UserProvider>
  );
}

export default App;

my server.js file


const PORT = process.env.PORT || 3000;
const server = app.listen(PORT, () => {
  console.log(`Server listening on ${PORT}`);
});

const io = app.get("io");
io.attach(server);

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật