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.