可以使用node-libcurl设置原始标头吗? [英] Can You Set An Origin Header Using node-libcurl?
本文介绍了可以使用node-libcurl设置原始标头吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道您可以使用-H标头在cURL中设置原点:
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
是否有设置-H标头的 node-libcurl
方法?这是我当前的获取请求:
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()
推荐答案
未记录GET请求的自定义标头.但是从 POST请求示例中,我会尝试这样的事情:
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)
这篇关于可以使用node-libcurl设置原始标头吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文