gpt4 book ai didi

node.js - NodeJS http 和 https 模块有什么区别?

转载 作者:搜寻专家 更新时间:2023-11-01 00:06:26 24 4
gpt4 key购买 nike

我在我的项目中使用了 http 模块,但我的大部分“发布”请求都被 postman 阻止了。我读到这是一个 ssl 问题,经过一些研究我发现了另一个名为 https 的模块。

这是我当前的代码。

 var http = require('http');

var server = http.createServer(app);

最佳答案

嘿,确保 Postman 中的拦截器已关闭(它应该在顶部,“登录”按钮的左侧)

与 https 相关,如 Node.js v5.10.1 文档中所述

HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a separate module.

我曾经用它通过 https(端口 443)从我的服务器向其他服务器发出请求。

顺便说一句,你的代码不应该工作,试试这个

const http = require('http');
http.createServer( (request, response) => {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');

并使用http://127.0.0.1:8124在 postman ..希望它有所帮助

关于node.js - NodeJS http 和 https 模块有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36646146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com