Can You Set An Origin Header Using node-libcurl?

旧街凉风 提交于 2021-01-27 12:21:59

问题


I know that you can set the origin in cURL using a -H header like this:

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

is there a node-libcurl way of setting -H headers? 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()

回答1:


Custom headers for GET request are not documented. But judging from POST request examples, I'd try something like this:

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

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


来源:https://stackoverflow.com/questions/65054601/can-you-set-an-origin-header-using-node-libcurl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!