Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

368
Views
Can a server make a request to itself?

Good Morning, I've initialized a server object with the NodeJs Http package. After I successfully login to my github oauth, I redirect the user to one url. The goal is, after the user is redirected to the first url .. without user action they are immediately sent to the 2nd url. My issue is, in order for this to happen, my server object has to receive a request for a url that prompts that action. How do I send a url request to a self-created server object? I tried https.get and https.request .. but I believe that's more so for requesting data from outside servers and then manipulating the data in that instance. Is it possible write code/a function that makes a url request to a nodejs server object that you created?

Please help, Best

const server = http.createServer();
const port = 3000;
server.on("listening", listening_handler);
server.listen(port);
function listening_handler(){
    console.log(`Now Listening on Port ${port}`);
}


server.on("request", connection_handler);

function connection_handler(req, res)
{
    
    console.log(`New Request for ${req.url} from ${req.socket.remoteAddress}`);

    if(req.url === "/"){
        const authorization_endpoint = "https://github.com/login/oauth/authorize";
        let uri = querystring.stringify({client_id, scope});
        res.writeHead(302, {Location: `${authorization_endpoint}?${uri}`}).end();
        
    }
    else if (req.url.startsWith() === "/authorized"){

        res.writeHead(302, {Location: `${api1}`}).end();
        showPic2();

    }
    else if (req.url  === `${api2}`){
        res.writeHead(302, {Location: `${api2}`}).end();
    }


    function showPic2(){

        // Request to server for url 2 goes here.

    }

}

The catch is, I can only use nodejs packages.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!