hapijs / h2o2

Proxy handler for hapi.js
Other
165 stars 66 forks source link

Adding Headers to request before proxying "Version 8.3.2" #108

Closed goxr3plus closed 4 years ago

goxr3plus commented 4 years ago

Can we have a new example for version 8.3.2 ?

The below doesn't work for me

let { headers } = request
// console.log("Headers :",headers)
headers.retailerId = '101010'
headers.terminalId = '10101001'
// console.log("Headers2 :",headers)
console.log(request.url.search)
return {
 uri: `${service.hostname}:${service.port}${service.apiBase}/terminal-reports/date-range-summary${request.url.search}`,
 headers: {headers},
}
goxr3plus commented 4 years ago

@hueniverse

goxr3plus commented 4 years ago

Actually i found out how it works it's like :

let { headers } = request
delete headers.host
headers.retailerId = '101010'
headers.terminalId = '10101001'
return {
 uri: `${service.hostname}:${service.port}${service.apiBase}/terminal-reports/date-range-summary${request.url.search}`,
 headers,
}