'I am having difficulty passing information from client to server in AWS Cloud9 using nodejs

I have a question about AWS Cloud9 and nodejs.

I am using this nodejs tutorial to teach myself how to communicate between client side and server side:

https://dev.to/gbudjeakp/how-to-connect-your-client-side-to-your-server-side-using-node-and-express-2i71

I followed the tutorial and set it up on my laptop and everything worked fine. I even was able to figure out how to write the data sent from the client to a file using writeFileSync.

The problem is in trying to get it to work while on the Amazon Web Service Cloud9 integrated development environment.

When I run the index.js file by itself on Cloud9, I get the message stating that the server is running on port 8080, as expected.

However, I cannot get the HTML file to interface with the index.js file. The HTML file contains a form that is supposed to send the form content to index.js.

I believe the problem is in the address contained in the HTML form. I have researched and tried several different configurations, but none of them work. Currently, the form looks like this:

<form action="https://localhost:8080/login" method="POST">
        <input type="text" name="username" placeholder="username">
        <input type="text" name="password" placeholder="password">
        <button type="submit">Login</button>
    </form>

Using localhost:8080 results in an error message of "localhost refused to connect."

When I have used variations of my username and AWS project name, I receive an error stating that the server IP address could not be found.

Any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source