App restarts when I make an api call through firebase functions

I’m fairly new to google firebase functions.

For some reason when my frontend makes an api call to the backend, the app looks like it restarts everything. Im not sure why. The endpoints are correct. I get a console message from the backend. Here is my code for reference

const express = require("express");
const functions = require("firebase-functions");
require("dotenv").config();

const cors = require("cors");
const axios = require("axios");
const baseURL = "https://api.pledge.to/v1/organizations";
const myHeader = {
  "Authorization": `Bearer ${process.env.API_KEY}`,
};

// Instantiate the app here
const app = express();
app.use(cors());

app.get("/", (req, res) => {
  console.log("Hello World");
  res.status(200).send("baus");
});

app.get("/organizations", async (req, res) => {
  console.log("Making API call");
  console.log(req.query.cause_id);
  try {
    // eslint-disable-next-line max-len
    const response = await axios.get(baseURL+"?"+`cause_id=${req.query.cause_id}`, {
      headers: myHeader,
    });
    const data = await response.data;
    res.status(200).send(data);
    // res.json(data);
  } catch (error) {
    console.error(error);
    res.status(500).json({error: "Internal Server Error"});
  }
});

app.get("/searchOrg", async (req, res)=> {
  console.log("Search query >>>", req.query.q);
  try {
    const response = await axios.get(baseURL+"?"+`q=${req.query.q}`, {
      headers: myHeader,
    });
    const data = await response.data;
    res.status(200).send(data);
  } catch (error) {
    console.error(error);
    res.status(500).json({error: "Internal Server Error"});
  }
});

app.get("/next", async (req, res)=>{
  // console.log("Im in the next endpoint");
  // Using template literals
  let queryString = " ";
  // eslint-disable-next-line guard-for-in
  for (const key in req.query) {
    queryString += `${key}=${req.query[key]}&`;
  }
  // Remove the trailing '&' if necessary
  queryString = queryString.slice(0, -1);

  try {
    const response = await axios.get(baseURL+"?"+`${queryString}`, {
      headers: myHeader,
    });
    const data = await response.data;
    res.status(200).send(data);
    // res.json(data);
  } catch (error) {
    console.error(error);
    res.status(500).json({error: "Internal Server Error"});
  }
});

// Listen command
exports.api = functions.https.onRequest(app);

I tested it using firebase emulators:start. I made sure to update the endpoints on my frontend so that it sends the request to the right server.

I checked the network tab when I make the api call and it says I am getting a 101 status code and a type websocket Also for some reason the amount of time it is taking to process the request is pending

Any ideas why this could be happening? Could it be that I configured the hosting wrong for my frontend. Any help is appreciated. Thanks in advance. Happy coding!