Skip to content

Instantly share code, notes, and snippets.

@hasegawayosuke
Created October 20, 2020 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasegawayosuke/13776584718fb56cba2f9c8c5c100e9d to your computer and use it in GitHub Desktop.
Save hasegawayosuke/13776584718fb56cba2f9c8c5c100e9d to your computer and use it in GitHub Desktop.
got with proxy
const got = require('got')
const myGot = async (url) => {
const instance = got.extend({
hooks: {
beforeRequest: [
options => {
options.headers.Host = (new URL(url)).hostname
options.port = 8888
options.hostname = '127.0.0.1'
options.url = url
}
]
}
})
const response = await instance(url)
console.log(response)
}
myGot('http://utf-8.jp/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment