mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-07-27 07:45:41 +00:00
add stop btn to web interface
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
module.exports = {
|
||||
shouldUseLocalResponse : function(req,reqBody){
|
||||
//intercept all options request
|
||||
if(req.method == "OPTIONS"){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
dealLocalResponse : function(req,reqBody,callback){
|
||||
if(req.method == "OPTIONS"){
|
||||
callback(200,mergeCORSHeader(req.headers),"");
|
||||
}
|
||||
},
|
||||
|
||||
replaceRequestProtocol:function(req,protocol){
|
||||
@@ -18,6 +27,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
replaceResponseHeader: function(req,res,header){
|
||||
return mergeCORSHeader(req.headers, header);
|
||||
},
|
||||
|
||||
replaceServerResData: function(req,res,serverResData){
|
||||
@@ -28,4 +38,20 @@ module.exports = {
|
||||
|
||||
shouldInterceptHttpsReq :function(req){
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function mergeCORSHeader(reqHeader,originHeader){
|
||||
var targetObj = originHeader || {};
|
||||
|
||||
delete targetObj["Access-Control-Allow-Credentials"];
|
||||
delete targetObj["Access-Control-Allow-Origin"];
|
||||
delete targetObj["Access-Control-Allow-Methods"];
|
||||
delete targetObj["Access-Control-Allow-Headers"];
|
||||
|
||||
targetObj["access-control-allow-credentials"] = "true";
|
||||
targetObj["access-control-allow-origin"] = reqHeader['origin'] || "-___-||";
|
||||
targetObj["access-control-allow-methods"] = "GET, POST, PUT";
|
||||
targetObj["access-control-allow-headers"] = reqHeader['access-control-request-headers'] || "-___-||";
|
||||
|
||||
return targetObj;
|
||||
}
|
Reference in New Issue
Block a user