mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-25 01:01:29 +00:00
21 lines
519 B
JavaScript
21 lines
519 B
JavaScript
/*
|
|
sample:
|
|
redirect all http requests of httpbin.org to https
|
|
test:
|
|
curl 'http://httpbin.org/get?show_env=1' --proxy http://127.0.0.1:8001
|
|
expected response:
|
|
{ "X-Forwarded-Protocol": "https" }
|
|
*/
|
|
module.exports = {
|
|
*beforeSendRequest(requestDetail) {
|
|
if (requestDetail.url.indexOf('http://httpbin.org') === 0) {
|
|
const newOption = requestDetail.requestOptions;
|
|
newOption.port = 443;
|
|
return {
|
|
protocol: 'https',
|
|
requestOptions: newOption
|
|
};
|
|
}
|
|
}
|
|
};
|