简体   繁体   English

您可以使用 node-libcurl 设置原点 Header 吗?

[英]Can You Set An Origin Header Using node-libcurl?

I know that you can set the origin in cURL using a -H header like this:我知道您可以使用 -H header 像这样在 cURL 中设置原点:

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

is there a node-libcurl way of setting -H headers?是否有设置 -H 标头的node-libcurl方式? This is my current get request:这是我当前的获取请求:

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

Custom headers for GET request are not documented.没有记录 GET 请求的自定义标头。 But judging from POST request examples , I'd try something like this:但是从POST request examples来看,我会尝试这样的事情:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM