javascript - 快速/节点获取的套接字挂起错误
问题描述
根据 CloudFlare Analytics,在过去的几个小时内,我的网站收到了超过 30 万个请求。在此期间,我遇到了阻止我的网站加载 (DDoS) 的错误。
我一直收到这个错误,我一生都无法弄清楚如何解决这个问题......
错误:
FetchError: request to https://api.discordbots.co/v1/get/bots failed, reason: socket hang up
这是 /v1/get/bots 端点代码:
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
});
});
编辑:我正在从 nextjs 应用程序发出请求,如下所示:
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 } }
}
如果有人可以为此提供可行的解决方案,我将不胜感激,这压力太大了。
解决方案
推荐阅读
- python - 在 Pandas 中按组标记序列
- python-3.x - 获取:AttributeError:“list”对象在尝试运行 NLP 分类模型时没有属性“lower”
- css - 有没有办法标准化表情符号的大小和宽度?
- java - 如何使spring data jpa生成的方法在空参数上抛出异常
- bash - 在 bash 脚本中使用 shell 字符串和参数运行 docker exec 命令
- api - YouTube 的 API 是否有术语表?
- .net - 在 .NET 中读取带有相反十进制字符(句点/逗号)格式的数字的 XML
- arrays - 如何验证 api 响应数组是否包含在 Chai 中没有索引的值
- c++ - 如何使用单例模式创建不同的实例?
- r - Error using fitdist in R - dllogis function must be defined