The trick to setting up a Sails.js app with a remote Postgres database hosted on Heroku is all about SSL. Here's how you do it:
Note: This is for Sails v0.9.x, the stable release at the time of this writing.
In Sails v0.10.x, the
config/adapters.js
file has been replaced withconfig/connections.js
You'll also want to replace themodule
key withadapter
.It should work anyways, since backwards compatibility for the old config is built-in, but that compatibility will be dropped prior to v1.0, so you might as well set it up to use the latest and greatest.
// ....
'db-core': {
module: 'sails-postgresql',
host: process.env.PG_HOSTNAME' || localhost',
user: process.env.PG_USER || 'root',
password: process.env.PG_PASSWORD || '',
database: process.env.PG_DATABASE || 'name_of_your_db',
port: process.env.PG_PORT || 5432,
ssl: {
rejectUnauthorized: false
}
}
// ....
host: process.env.PG_HOSTNAME' || localhost',
Looks like a typo. :)