How to redirect incoming URL requests by adding additional parameters

后端 未结 3 535
慢半拍i
慢半拍i 2021-01-14 18:56

Problem: I get an incoming HTTP request to my server application. The request is something like this : http://example.com?id=abc. I need to parse this request, patch additio

3条回答
  •  春和景丽
    2021-01-14 19:12

    Just wondering if a simpler redirect would serve the purpose:

      function onRequest(request,response) {
        if(request.method =='GET') {
           sys.debug("in get");
           var pathName = url.parse(request.url).pathname;
           sys.debug("Get PathName" + pathName + ":" + request.url);
           var myidArr = request.url.split("=");
           var myid = myidArr[1];
           var path = 'http://localhost:8080/temp.html?id=' + myid + '&name=cdf';
           response.writeHead(302, {'Location': path});
           response.end();
        }
    

提交回复
热议问题