Home>

Help, I am super newcomer, I need help if in short: I created a server application using a nodejs with a database connection, I went to it for 2-3 weeks, now I can withdraw data from the database, and render them to your page, I registered on AWS (Amazon) Windows Servak, installed There is a node, and now I have a remotely via RDP, my server is started at http: //Localhost: 3000 /, how can I redirect all requests from the Internet now on my Windows Avs Servak? Only in more detail please, the majority of code I copied and faked for myself. Public IPv4 DNS -Example.com Public IPv4 Address -3.123.84.11 **

My code:

**

Let Express= Require ('Express')
Let Mysql= Require ('MySQL');
Let Conn= MySQL.CreateConnection ({
    HOST: #############
    User: #############
    Password: '#############',
    Database: '#############'
  });
Let Query= "Select * #############";
Let Current_Products= [];
FUNCTION F () {
    RETURN NEW PROMISE (RESOLVE= >
 {
        Conn.Connect (FUNCTION (ERR) {
            If (ERR) Throw ERR;
            Console.log ("Connected!");
            Conn.Query (Query, Function (ERR, RESULT) {
                If (Err) Throw ERR
                RESOLVE (RESULT);
            });
        });
    })
}
ASYNC FUNCTION ASYNCCALL () {
    Current_Products= AWAIT F ();
    Current_Products= JSON.PARSE (JSON.Stringify (Current_Products)). SPLICE (0,1)
    Console.log (Current_Products);
}
asynccall ();
const port= process.env.port ?? 3000.
Const App= Express ()
app.listen (port, ()= >
 {
    Console.log (`Server Hes Been Started On Port $ {port} ...`);
})
App.USE (express.static (__ dirname));
App.Get ('/index', (Req, Res)= >
{
    res.json (Current_Products [0]);
})

code in index.html:

<
Script Type= "Text /JavaScript" >
    Let url= "http: //Localhost: 3000 /index";
    Fetch (URL) .Then (response= >
 response.json ()
        .Then ((Result)= >
 {
            Let NameProd= Document.QuerySelector ('. Products__Name')
            nameprod.innerhtml= `name: $ {result.column_2}`
            Let IMGProd= Document.QuerySelector (". Products__Image")
            imgprod.innerhtml= `<
img src= "$ {result.column_15}" ">
`
        }). Catch (Error= >
 Console.log ('Error:', Error)))
≪
/script >
  • Answer # 1

    If short, then it was necessary to just run your app.js to 80 ports, before

  • Answer # 2

    If short, then it was necessary to just run your app.js to 80 ports, before