Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:17:12+00:00 2026-06-04T16:17:12+00:00

Problem: I get an incoming HTTP request to my server application. The request is

  • 0

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 additional URL parameters and call a hosted html file. So:

http://example.com?id=abc => http://example.com:8080/temp.html?id=abc&name=cdf.

So the client should see temp.html

Here’s the code:

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];
        //Call the redirect function
        redirectUrl(myid);
}
http.createServer(onRequest).listen(8888);

function redirectUrl(myid) {
var temp='';
    var options = {
      host: 'localhost',
      port: 8080,
      path: '/temp.html?id=' + myid + '&name=cdf',
      method: 'GET'
    };
  var req = http.request(options, function(res) {
    console.log('STATUS: ' + res.statusCode);
    console.log('HEADERS: ' + JSON.stringify(res.headers));
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
      temp = temp.concat(chunk);
    });
    res.on('end', function(){
        return temp;
      });
    });
  req.end();
  return temp;
}

Even though this is a really stupid way of going about this issue, I do see the response in the res.end() callback. How to propagate this to the parent calling function onRequest ?

Is there a simpler way of doing this just using node ? I know that there are ways to serve static html files. However, I need to pass URL parameters to temp.html – so I’m not sure how to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:17:13+00:00Added an answer on June 4, 2026 at 4:17 pm

    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();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: to get the command working here. My domain is http://cs.edu.com/user/share_dir , but I
Hi I get problem retrieve XML data from SQL2000 server. The table structure is
I get this problem when referring to OpenFEC (openfec.org)-functions in my code: anders@ubuntu:~/workspace/fectest$ gcc
I get this problem while doing some experiment with set . I use a
I periodically get this problem where all of a sudden mako is using old
I'm having a problem. I get incoming time strings in 12-hour format, and I'm
I have a repository in here http://repos.joomlaguruteam.com/ I using hgweb.cgi this is my hgweb.config
Please help to solve this small problem: I try to decode incoming jpg data
Given two tables: (incoming greatly reduced/simplified example that exhibits the key problem) app_data represents
I have a problem with redirecting requests. I have an incoming GET or POST

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.