Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

376
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda