node-libcurl을 사용하여 원본 헤더를 설정할 수 있습니까?
Nov 28 2020
다음과 같이 -H 헤더를 사용하여 cURL에서 원점을 설정할 수 있다는 것을 알고 있습니다.
curl -H "Origin: http://foo.bar.com" --verbose \
https://example.com
node-libcurl
-H 헤더를 설정 하는 방법이 있습니까? 이것은 내 현재 받기 요청입니다.
const { curly } = require('node-libcurl')
async function test(){
mm = await curly.get('https://example.com')
console.log(mm)
}
test()
답변
1 ΔO'deltazero' Nov 28 2020 at 23:38
GET 요청에 대한 사용자 정의 헤더는 문서화되지 않았습니다. 그러나 POST 요청 예제 에서 판단하면 다음과 같이 시도합니다.
const { curly } = require('node-libcurl')
curly.get('https://example.com', {
httpHeader: [
'Origin: http://foo.bar.com',
...
]
}).then(console.log)