这个网址http:有什么特别之处吗?
- 内容介绍
- 文章标签
- 相关推荐
本文共计820个文字,预计阅读时间需要4分钟。
目录+正文+命令行启动服务器+详细的调用栈+错误捕捉+正文+使用下面这段简单的代码对网络请求进行代理:javascriptconst http=require('http');const httpProxy=require('http-proxy');const targetUrl='https://www.';
目录
- 正文
- 命令行启动服务器
- 详细的调用栈
- 捕捉错误
正文
使用下面这段简单的代码对网络请求进行代理:
const www.sap.cn/index.html'; const proxy = httpProxy.createProxyServer({ target: targetUrl, }); http.createServer(function (req, res) { proxy.web(req, res); }).listen(8089); console.log('Proxy listens in 8089');
这段代码的语义是,创建一个代理 HTTP 服务器,监听在端口 8089 上。
因此该代理服务器接收到任何发送到 8089 端口的 HTTP 请求,都会自动将其发送到 targetUrl 指定的 sap 网站上。
本文共计820个文字,预计阅读时间需要4分钟。
目录+正文+命令行启动服务器+详细的调用栈+错误捕捉+正文+使用下面这段简单的代码对网络请求进行代理:javascriptconst http=require('http');const httpProxy=require('http-proxy');const targetUrl='https://www.';
目录
- 正文
- 命令行启动服务器
- 详细的调用栈
- 捕捉错误
正文
使用下面这段简单的代码对网络请求进行代理:
const www.sap.cn/index.html'; const proxy = httpProxy.createProxyServer({ target: targetUrl, }); http.createServer(function (req, res) { proxy.web(req, res); }).listen(8089); console.log('Proxy listens in 8089');
这段代码的语义是,创建一个代理 HTTP 服务器,监听在端口 8089 上。
因此该代理服务器接收到任何发送到 8089 端口的 HTTP 请求,都会自动将其发送到 targetUrl 指定的 sap 网站上。

