express-demo
An Express Demo App
Posted on July 3, 2019
I had this small side project I worked on for a client over a weekend, it was a simple express API.
Everything worked well and good until it was time to deploy! This was my conversation with the client..
Me: Cool so the app is ready, can you send me your staging server details so i can deploy for you?
Client: Yea cool, i will send you an RDP credentials to our Windows VM
Me: Wait what?
Ok jokes apart, lets get straight into it!
Before we continue, you should have a basic knowledge of Setting up a simple Express App and using Nodemon or any other Node Process manager.
To speed things up, i have setup a simple express app with a single endpoint for this demo, please note that the target is not necessarily an introduction to Express but how to deploy an Express based app on Windows.
You can clone the repo to follow along.
If you are using the sample app that was cloned, run yarn
and then yarn start
. The app should now start with nodemon
. Assuming you have not changed the default port, head over to your browser at http://localhost:3000 . you should see the sample json response as below
{
status: true,
data: "Api Works"
}
Now the app is running locally but not available outside the server. What we want is for the public to be able to reach the app at http://yourdomain.com/app
where http://yourdomain.com
is our domain.
Search and open Internet Information Services (IIS)
Expand Sites -> Default Web Site
Right click on Default Web Site and select Add Application
Make sure the newly created app is selected under the Default Web Site, click on URL Rewrite from the IIS dashboard on the right.
On the right, click on Add Rule(s) and then select Reverse Proxy
On the inbound rules dialogue box, enter localhost:3000
as illustrated below.
If you changed the port number where the express app is currently running, make sure you use
localhost:{port_number}
Click on OK after this.
Now head over to a browser (outside your server) and try to access http://yourdomain.com/api (where http://yourdomain.com) is your actual domain name.
Posted on July 3, 2019
Sign up to receive the latest update from our blog.