小编Lef*_*ver的帖子

在node.js中如何获取请求对象的协议?

const URL = require('url').URL;
const myURL = new URL('https://example.org/foo');

console.log(myURL.href);     // https://example.org/foo
console.log(myURL.protocol); // https:
console.log(myURL.hostname); // example.org
console.log(myURL.pathname); // /foo
Run Code Online (Sandbox Code Playgroud)

但是我如何获取用户向服务器发出的请求 url ???

node.js

8
推荐指数
1
解决办法
9486
查看次数

在 node.js 中为什么我应该对 ssl 证书和密钥使用 readFileSync?使用 readFile 有哪些陷阱?

var privateKey  = fs.readFileSync('/path/to/franciskim.co.key', 'utf8');
var certificate = fs.readFileSync('/path/to/franciskim.co.crt', 'utf8');
var credentials = { key: privateKey, cert: certificate }; 
Run Code Online (Sandbox Code Playgroud)

为什么不只是 fs.readFile?为什么要读取文件同步?

node.js

3
推荐指数
1
解决办法
1975
查看次数

标签 统计

node.js ×2