Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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()
like image 922
imaginate Avatar asked Mar 24 '26 17:03

imaginate


1 Answers

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)
like image 155
ΔO 'delta zero' Avatar answered Mar 27 '26 07:03

ΔO 'delta zero'



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!