Sails.js + passport behind Nginx proxy
The answer is simple, but not very well documented. There's another post which actually talks about a slighty different problem, but leads to the correct answer:How to get current domain address in sails.js
If you're on Sails v0.10.x, you can use sails.getBaseurl() to get the full protocol, domain and port that your app is being served from. Starting with Sails v0.10.0-rc6, this also checks the sails.config.proxyHost and sails.config.proxyPort, which you can set manually in your one of your config files (like config/local.js) if your app is being served via a proxy (e.g. if it's deployed on Modulus.io, or proxied through an Nginx server).
It is correct to configure a sails instance to localhost:9090, but if you want to change the hostname/port behind a proxy, you have to configure proxyHost
and proxyPort
- this can be done anywhere, but is most suitable in local.js