1

I have a node server running on port 3000. I'll be using it to handle all my APIs, but I don't want the URLs to be in the format

example.com:3000/api/xyz 

I want it to be in the format:

example.com/api/.. 

How do I route all /api/ calls to port 3000?

example.com will be serving HTML pages, which have nothing to do with node. Node will only be used for APIs for now. I found Varnish, but it looks like overkill.

Coding Duchess
  • 6,445
  • 20
  • 113
  • 209
absk
  • 643
  • 1
  • 6
  • 15

1 Answers1

1

An easy way is to put nginx in front of your node server.

You can setup nginx to serve static media based on url patterns. You can also register non-static requests to be sent to an upstream node.js server on port 3000

Node.js + Nginx - What now?

Community
  • 1
  • 1
dm03514
  • 54,664
  • 18
  • 108
  • 145