小编Lum*_*uma的帖子

Deno 部署 - 请求时未定义 IP 地址

我在 Deno 上使用expressmongo,并且我也尝试使用express-rate-limit,但是,我在速率限制上收到以下错误,因为request.ip未定义:

ValidationError: An undefined 'request.ip' was detected. This might indicate a misconfiguration or the connection being destroyed prematurely. See https://express-rate-limit.github.io/ERR_ERL_UNDEFINED_IP_ADDRESS/ for more information.
    at Object.ip (file:///node_modules/.deno/express-rate-limit@7.1.5/node_modules/express-rate-limit/dist/index.mjs:97:13)
    at Object.wrappedValidations.<computed> [as ip] (file:///node_modules/.deno/express-rate-limit@7.1.5/node_modules/express-rate-limit/dist/index.mjs:296:22)
    at Object.keyGenerator (file:///node_modules/.deno/express-rate-limit@7.1.5/node_modules/express-rate-limit/dist/index.mjs:549:20)
    at file:///node_modules/.deno/express-rate-limit@7.1.5/node_modules/express-rate-limit/dist/index.mjs:601:32
    at Object.runMicrotasks (ext:core/01_core.js:934:26)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:53:10)
    at runNextTicks (ext:deno_node/_next_tick.ts:71:3)
    at eventLoopTick (ext:core/01_core.js:189:21)
    at async file:///node_modules/.deno/express-rate-limit@7.1.5/node_modules/express-rate-limit/dist/index.mjs:583:5 {
  name: "ValidationError",
  code: "ERR_ERL_UNDEFINED_IP_ADDRESS",
  help: "https://express-rate-limit.github.io/ERR_ERL_UNDEFINED_IP_ADDRESS/"
}
Run Code Online (Sandbox Code Playgroud)

我在一个类似的问题上找到了这个答案,建议添加app.set('trust proxy', 1);我尝试过,但 ip 仍然未定义。

如何重现:

"use …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js express deno express-rate-limit

5
推荐指数
0
解决办法
82
查看次数

标签 统计

deno ×1

express ×1

express-rate-limit ×1

mongodb ×1

node.js ×1