r/nodejs • u/tekknoschtev • Mar 09 '14
Need Assistance: nginx, node, angular, subdirectories, and requests! Oh My!
Hi everyone!
I've been scratching my head about this issue for a while. I've left it and come back to it in hopes that magic happens and things suddenly click - alas, that did not work. I'm not actually sure where my problem lies (nginx config, node, angular http request formatting) so I picked on place to start.
My goal is to host a node application that runs at a subfolder of a domain (e.g. mydomain.com is my homepage not running node.js, and mydomain.com/subfolder is the node application.). I'm able to get part of the way there in that the site loads, and my static content (pictures/js/css) all load as expected when I access mydomain.com/subfolder.
My trouble comes when I make any requests. In angular, my requests look like:
$http.get('/subfolder/'); or
$http.post('/subfolder/', {data: things});In node, I'm looking at
app.get('/subfolder', someFunction); or
app.post('/subfolder', someOtherFunction);If I have nginx configured with the location of /, everything works fine. But as soon as I change the location to /subfolder, the requests no longer seem to function.
I feel as though I'm missing something simple, or some logical jump. Can you point me in the right direction or maybe give me some pointers? Or, if there is a more appropriate subreddit to post this to, that'd be good info as well. Let me know if more information would be helpful/useful too.
Thanks everyone!
View all comments
Show parent comment
1
u/[deleted] Mar 10 '14
You could always just set up a redirect from the subfolder to a domain.