Skip to content

Instantly share code, notes, and snippets.

@banyudu
Created February 3, 2020 08:06
Show Gist options
  • Select an option

  • Save banyudu/bd8b2ad63eb0b187cb64b9df664ef90e to your computer and use it in GitHub Desktop.

Select an option

Save banyudu/bd8b2ad63eb0b187cb64b9df664ef90e to your computer and use it in GitHub Desktop.
setup axios proxy with shadowsocks
// change host / port / protocol to your real values
const axiosOptions: AxiosRequestConfig = {}
const httpsAgent = new SocksProxyAgent({
host: '127.0.0.1',
port: 1086,
protocol: 'socks5:',
rejectUnauthorized: false
})
axiosOptions.httpAgent = httpsAgent
axiosOptions.httpsAgent = httpsAgent
axiosOptions.proxy = false
process.env.NODE_TLS_REJECT_UNAUTHORIZED = null // dangerous, do not use in production.
export const rest = axios.create(axiosOptions)
// rest.get('https://google.com')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment