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.