1
votes

My idea is to split the client static files and the nodejs server. In production i will most likely serve the static files from nginx directly and proxy everything with an /api/ route to the node app.

In development I thought I can achieve the same by a simple nodejs app but i have no idea how to set this up. Currently my client files are serverd on port 9000 via a grunt dev server and the api is on port 3000. Is there an easy way to write a node app which redirects every request which doesn't start with /api/ to port 9000 and all other traffic to port 3000?

1
I tried the same thing with node-proxy but I didn't manage it. I ended with a local configuration with Apache mod_proxy but I think nginx is even easier to configure.hgoebl
You can view my configuration at gist.github.com/hgoebl/7694751hgoebl

1 Answers

0
votes

I've found a nice grunt package which does the job:

grunt-connect-proxy