1

According to CloudFlare Analytics, I have over 300k requests made to my website in the past couple of hours. And during this time, I have been getting errors which prevents my site from loading (DDoS).

I have been getting this error and cannot figure out for the life of me how I can resolve this...

Error:

FetchError: request to https://api.discordbots.co/v1/get/bots failed, reason: socket hang up

And this is the /v1/get/bots endpoint code:

this.router.get("/v1/get/bots", (req: Request, res: Response, next) => {
    if (!this.isAuthorized(req)) return res.status(401).send({
        error: true,
        response: "Invalid authorization key."
    });

    return res.status(200).send({
        error: false,
        response: this.client.botUpdater.bots
    });
});

EDIT: I am making the request from a nextjs application as shown:

export async function getServerSideProps(context) {
  const response: Response = await fetch(`${process.env.API}/v1/get/bots`, {
    headers: {
      "Authorization": process.env.AUTHORIZATION as string
    }
  });
  const result = await response.json();

  return { props: { bots: result.response ? result.response : null, error: result.error, loading: false } }
}

I would highly appreciate if somebody can provide a working solution to this, this has been so stressful.

Vultrex
  • 21
  • 3
  • Where is the error thrown? Does this question help you with your problem? https://stackoverflow.com/questions/16995184/nodejs-what-does-socket-hang-up-actually-mean – FelHa Nov 25 '20 at 18:02
  • The error is thrown on my frontend (nextjs app) and spams the console with it. I have edited my original post to include the code snippet for the frontend. And I seen that earlier today but sadly it did not help. – Vultrex Nov 25 '20 at 18:25

0 Answers0