node.js - 您可以使用 node-libcurl 设置源 header 吗?

标签 node.js get node-libcurl

我知道您可以像这样使用 -H header 在 cURL 中设置原点:

curl -H "Origin: http://foo.bar.com" --verbose \
  https://example.com

是否有 node-libcurl 设置 -H header 的方法?这是我当前的获取请求:

const { curly } = require('node-libcurl')
async function test(){
  mm = await curly.get('https://example.com')
  console.log(mm)
}
test()

最佳答案

GET 请求的自定义 header 未记录。但是从POST request examples来看,我会尝试这样的事情:

const { curly } = require('node-libcurl')

curly.get('https://example.com', {
    httpHeader: [
        'Origin: http://foo.bar.com',
        ...
    ]
}).then(console.log)

关于node.js - 您可以使用 node-libcurl 设置源 header 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65054601/

相关文章:

javascript - 得到类型错误 : Cannot read property 'passes' of undefined using Cypress when generating mochawesome report

linux - 在Jenkins中使用maven exec插件运行nodejs

javascript - Node.js:响应是否发送给正确的用户?

使用 GET 参数时 Apache Redirect 301 失败,例如 ?blah=

node.js - 由于node-libcurl,命令 npm install 失败

node.js - node-libcurl 在 POST 上获取错误的 IP 地址

node.js - Alexa 技能 : is it possible to pause and resume the skill programmatically?

shell - 获取用于启动脚本的命令

javascript - flask 形式和javascript