Reputation: 4306
I have a website, let's say mywebsite.com I am using node and express for the middleware and point to mysite.com:3011/api To make my middleware calls. Hosting the site statically in ubuntu 16 (Linux) and running the middleware separately using pm2 (node server)
I would like to simply be able to do something like mysite.com/API without specifying a port in the API call.
Today I tried to demo the site at a corporate office and the apis failed due to not allowing a port to be specified in the URL.
Upvotes: 0
Views: 52
Reputation: 41
You can use a reverse proxy (like nginx) to hide this port and forward the request to your Node.js api. Something like this:
server {
listen 80;
...
location / {
root /path/to/static/files;
}
location /api {
rewrite ^/api(.*) /$1 break;
proxy_pass http://127.0.0.1:3011;
}
...
}
Upvotes: 0