检查 Node.js 应用程序中的出站 HTTP 请求

huangapple go评论58阅读模式
英文:

Inspecting outgoing HTTP requests in a nodejs application

问题

我正在使用NestJS构建一个Web应用程序,从中调用外部API以检索数据。现在,我想检查从我的应用程序发送的所有请求。例如,在Web浏览器中,我可以通过控制台检查我发送到服务器的所有请求。

您能否指导我如何实现这一目标?无论是在Node.js、NestJS中,还是通过使用其他软件。

注意:我正在使用node-fetch进行网络调用。

英文:

I am using NestJS to build a web app from which I call an external API to retrieve data. Now, I want to inspect all the requests that are sent from my app. For example, in a web browser, I can inspect all the requests I send to my server through the console.

Could you please advise on how I can achieve this? Whether it's in Node.js, NestJS, or by using some other software.

NOTE: I am using node-fetch to make network calls.

答案1

得分: 1

  1. 如果您的服务部署在GCP云运行的任何无服务器平台上,如Cloud Run、Cloud Functions、App Engine,那么控制台日志将被流式传输到日志浏览器。

  2. 另一种可能的方式是构建您自己的日志流式传输服务或使用Winston日志记录器在文件中创建日志转储。

  3. 市场上有一些可用工具,如果以所需方式传递数据,它们可以在其仪表板中以表格格式显示日志。易于使用过滤器监视和查询。

英文:
  1. If your service is deployed in any serverless platform for GCP cloud run, cloud functions, app engine then console logs will be streamed in log explorers.

  2. Other possible way is build your own log streaming service or create log dumps in a file using winston logger.

  3. There are few available tools in market for which if u pass your data in a required manner they can show the logs in table format in their dashboard. Easy to monitor and query with filters

答案2

得分: 0

除了记录node-fetch的HTTP调用外,我不认为有内置工具用于发送HTTP请求。

英文:

Outside of logging the node-fetch http calls, I don't believe there is a built-in tool for outgoing http requests.

答案3

得分: -1

我找到了解决方法,有一个工具(httptoolkit)可以检查从任何地方(浏览器、容器、终端等)发送的所有请求。

英文:

I found the solution, there is a tool (httptoolkit) that allows to inspect all the requests that are sent from anywhere (browser, container, terminal ...)

huangapple
  • 本文由 发表于 2023年6月9日 05:04:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76435679.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定