production.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. /**
  2. * Production environment settings
  3. * (sails.config.*)
  4. *
  5. * What you see below is a quick outline of the built-in settings you need
  6. * to configure your Sails app for production. The configuration in this file
  7. * is only used in your production environment, i.e. when you lift your app using:
  8. *
  9. * ```
  10. * NODE_ENV=production node app
  11. * ```
  12. *
  13. * > If you're using git as a version control solution for your Sails app,
  14. * > this file WILL BE COMMITTED to your repository by default, unless you add
  15. * > it to your .gitignore file. If your repository will be publicly viewable,
  16. * > don't add private/sensitive data (like API secrets / db passwords) to this file!
  17. *
  18. * For more best practices and tips, see:
  19. * https://sailsjs.com/docs/concepts/deployment
  20. */
  21. module.exports = {
  22. /**************************************************************************
  23. * *
  24. * Tell Sails what database(s) it should use in production. *
  25. * *
  26. * (https://sailsjs.com/config/datastores) *
  27. * *
  28. **************************************************************************/
  29. datastores: {
  30. /***************************************************************************
  31. * *
  32. * Configure your default production database. *
  33. * *
  34. * 1. Choose an adapter: *
  35. * https://sailsjs.com/plugins/databases *
  36. * *
  37. * 2. Install it as a dependency of your Sails app. *
  38. * (For example: npm install sails-mysql --save) *
  39. * *
  40. * 3. Then set it here (`adapter`), along with a connection URL (`url`) *
  41. * and any other, adapter-specific customizations. *
  42. * (See https://sailsjs.com/config/datastores for help.) *
  43. * *
  44. ***************************************************************************/
  45. default: {
  46. // adapter: 'sails-mysql',
  47. // url: 'mysql://user:password@host:port/database',
  48. //--------------------------------------------------------------------------
  49. // /\ To avoid checking it in to version control, you might opt to set
  50. // || sensitive credentials like `url` using an environment variable.
  51. //
  52. // For example:
  53. // ```
  54. // sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db
  55. // ```
  56. //--------------------------------------------------------------------------
  57. /****************************************************************************
  58. *                         *
  59. * More adapter-specific options *
  60. *                         *
  61. * > For example, for some hosted PostgreSQL providers (like Heroku), the *
  62. * > extra `ssl: true` option is mandatory and must be provided. *
  63. *                         *
  64. * More info:                   *
  65. * https://sailsjs.com/config/datastores           *
  66. *                         *
  67. ****************************************************************************/
  68. // ssl: true,
  69. },
  70. },
  71. models: {
  72. /***************************************************************************
  73. * *
  74. * To help avoid accidents, Sails automatically sets the automigration *
  75. * strategy to "safe" when your app lifts in production mode. *
  76. * (This is just here as a reminder.) *
  77. * *
  78. * More info: *
  79. * https://sailsjs.com/docs/concepts/models-and-orm/model-settings#?migrate *
  80. * *
  81. ***************************************************************************/
  82. migrate: 'safe',
  83. /***************************************************************************
  84. * *
  85. * If, in production, this app has access to physical-layer CASCADE *
  86. * constraints (e.g. PostgreSQL or MySQL), then set those up in the *
  87. * database and uncomment this to disable Waterline's `cascadeOnDestroy` *
  88. * polyfill. (Otherwise, if you are using a databse like Mongo, you might *
  89. * choose to keep this enabled.) *
  90. * *
  91. ***************************************************************************/
  92. // cascadeOnDestroy: false,
  93. },
  94. /**************************************************************************
  95. * *
  96. * Always disable "shortcut" blueprint routes. *
  97. * *
  98. * > You'll also want to disable any other blueprint routes if you are not *
  99. * > actually using them (e.g. "actions" and "rest") -- but you can do *
  100. * > that in `config/blueprints.js`, since you'll want to disable them in *
  101. * > all environments (not just in production.) *
  102. * *
  103. ***************************************************************************/
  104. blueprints: {
  105. shortcuts: false,
  106. },
  107. /***************************************************************************
  108. * *
  109. * Configure your security settings for production. *
  110. * *
  111. * IMPORTANT: *
  112. * If web browsers will be communicating with your app, be sure that *
  113. * you have CSRF protection enabled. To do that, set `csrf: true` over *
  114. * in the `config/security.js` file (not here), so that CSRF app can be *
  115. * tested with CSRF protection turned on in development mode too. *
  116. * *
  117. ***************************************************************************/
  118. security: {
  119. /***************************************************************************
  120. * *
  121. * If this app has CORS enabled (see `config/security.js`) with the *
  122. * `allowCredentials` setting enabled, then you should uncomment the *
  123. * `allowOrigins` whitelist below. This sets which "origins" are allowed *
  124. * to send cross-domain (CORS) requests to your Sails app. *
  125. * *
  126. * > Replace "https://example.com" with the URL of your production server. *
  127. * > Be sure to use the right protocol! ("http://" vs. "https://") *
  128. * *
  129. ***************************************************************************/
  130. cors: {
  131. // allowOrigins: [
  132. // 'https://example.com',
  133. // ]
  134. },
  135. },
  136. /***************************************************************************
  137. * *
  138. * Configure how your app handles sessions in production. *
  139. * *
  140. * (https://sailsjs.com/config/session) *
  141. * *
  142. * > If you have disabled the "session" hook, then you can safely remove *
  143. * > this section from your `config/env/production.js` file. *
  144. * *
  145. ***************************************************************************/
  146. session: {
  147. /***************************************************************************
  148. * *
  149. * Production session store configuration. *
  150. * *
  151. * Uncomment the following lines to finish setting up a package called *
  152. * "connect-redis" that will use Redis to store and retrieve session data. *
  153. * This makes your app more scalable by allowing you to share sessions *
  154. * across a cluster of multiple Sails/Node.js servers and/or processes. *
  155. * (See http://bit.ly/redis-session-config for more info.) *
  156. * *
  157. * > While "connect-redis" is a popular choice for Sails apps, many other *
  158. * > compatible packages (like "connect-mongo") are available on NPM. *
  159. * > (For a full list, see https://sailsjs.com/plugins/sessions) *
  160. * *
  161. ***************************************************************************/
  162. // adapter: 'connect-redis',
  163. // url: 'redis://user:password@localhost:6379/dbname',
  164. //--------------------------------------------------------------------------
  165. // /\ OR, to avoid checking it in to version control, you might opt to
  166. // || set sensitive credentials like this using an environment variable.
  167. //
  168. // For example:
  169. // ```
  170. // sails_session__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/sessions
  171. // ```
  172. //
  173. //--------------------------------------------------------------------------
  174. /***************************************************************************
  175. * *
  176. * Production configuration for the session ID cookie. *
  177. * *
  178. * Tell browsers (or other user agents) to ensure that session ID cookies *
  179. * are always transmitted via HTTPS, and that they expire 24 hours after *
  180. * they are set. *
  181. * *
  182. * Note that with `secure: true` set, session cookies will _not_ be *
  183. * transmitted over unsecured (HTTP) connections. Also, for apps behind *
  184. * proxies (like Heroku), the `trustProxy` setting under `http` must be *
  185. * configured in order for `secure: true` to work. *
  186. * *
  187. * > While you might want to increase or decrease the `maxAge` or provide *
  188. * > other options, you should always set `secure: true` in production *
  189. * > if the app is being served over HTTPS. *
  190. * *
  191. * Read more: *
  192. * https://sailsjs.com/config/session#?the-session-id-cookie *
  193. * *
  194. ***************************************************************************/
  195. cookie: {
  196. // secure: true,
  197. maxAge: 24 * 60 * 60 * 1000, // 24 hours
  198. },
  199. },
  200. /**************************************************************************
  201. * *
  202. * Set up Socket.io for your production environment. *
  203. * *
  204. * (https://sailsjs.com/config/sockets) *
  205. * *
  206. * > If you have disabled the "sockets" hook, then you can safely remove *
  207. * > this section from your `config/env/production.js` file. *
  208. * *
  209. ***************************************************************************/
  210. sockets: {
  211. /***************************************************************************
  212. * *
  213. * Uncomment the `onlyAllowOrigins` whitelist below to configure which *
  214. * "origins" are allowed to open socket connections to your Sails app. *
  215. * *
  216. * > Replace "https://example.com" etc. with the URL(s) of your app. *
  217. * > Be sure to use the right protocol! ("http://" vs. "https://") *
  218. * *
  219. ***************************************************************************/
  220. // onlyAllowOrigins: [
  221. // 'https://example.com',
  222. // 'https://staging.example.com',
  223. // ],
  224. /***************************************************************************
  225. * *
  226. * If you are deploying a cluster of multiple servers and/or processes, *
  227. * then uncomment the following lines. This tells Socket.io about a Redis *
  228. * server it can use to help it deliver broadcasted socket messages. *
  229. * *
  230. * > Be sure you have a compatible version of socket.io-redis installed! *
  231. * > (See https://sailsjs.com/config/sockets for the latest version info) *
  232. * *
  233. * (https://sailsjs.com/docs/concepts/deployment/scaling) *
  234. * *
  235. ***************************************************************************/
  236. // adapter: 'socket.io-redis',
  237. // url: 'redis://user:password@bigsquid.redistogo.com:9562/dbname',
  238. //--------------------------------------------------------------------------
  239. // /\ OR, to avoid checking it in to version control, you might opt to
  240. // || set sensitive credentials like this using an environment variable.
  241. //
  242. // For example:
  243. // ```
  244. // sails_sockets__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/
  245. // ```
  246. //--------------------------------------------------------------------------
  247. },
  248. /**************************************************************************
  249. * *
  250. * Set the production log level. *
  251. * *
  252. * (https://sailsjs.com/config/log) *
  253. * *
  254. ***************************************************************************/
  255. log: {
  256. level: 'debug'
  257. },
  258. http: {
  259. /***************************************************************************
  260. * *
  261. * The number of milliseconds to cache static assets in production. *
  262. * (the "max-age" to include in the "Cache-Control" response header) *
  263. * *
  264. ***************************************************************************/
  265. cache: 365.25 * 24 * 60 * 60 * 1000, // One year
  266. /***************************************************************************
  267. * *
  268. * Proxy settings *
  269. * *
  270. * If your app will be deployed behind a proxy/load balancer - for example, *
  271. * on a PaaS like Heroku - then uncomment the `trustProxy` setting below. *
  272. * This tells Sails/Express how to interpret X-Forwarded headers. *
  273. * *
  274. * This setting is especially important if you are using secure cookies *
  275. * (see the `cookies: secure` setting under `session` above) or if your app *
  276. * relies on knowing the original IP address that a request came from. *
  277. * *
  278. * (https://sailsjs.com/config/http) *
  279. * *
  280. ***************************************************************************/
  281. // trustProxy: true,
  282. },
  283. /**************************************************************************
  284. * *
  285. * Lift the server on port 80. *
  286. * (if deploying behind a proxy, or to a PaaS like Heroku or Deis, you *
  287. * probably don't need to set a port here, because it is oftentimes *
  288. * handled for you automatically. If you are not sure if you need to set *
  289. * this, just try deploying without setting it and see if it works.) *
  290. * *
  291. ***************************************************************************/
  292. // port: 80,
  293. /**************************************************************************
  294. * *
  295. * Configure an SSL certificate *
  296. * *
  297. * For the safety of your users' data, you should use SSL in production. *
  298. * ...But in many cases, you may not actually want to set it up _here_. *
  299. * *
  300. * Normally, this setting is only relevant when running a single-process *
  301. * deployment, with no proxy/load balancer in the mix. But if, on the *
  302. * other hand, you are using a PaaS like Heroku, you'll want to set up *
  303. * SSL in your load balancer settings (usually somewhere in your hosting *
  304. * provider's dashboard-- not here.) *
  305. * *
  306. * > For more information about configuring SSL in Sails, see: *
  307. * > https://sailsjs.com/config/*#?sailsconfigssl *
  308. * *
  309. **************************************************************************/
  310. // ssl: undefined,
  311. /**************************************************************************
  312. * *
  313. * Production overrides for any custom settings specific to your app. *
  314. * (for example, production credentials for 3rd party APIs like Stripe) *
  315. * *
  316. * > See config/custom.js for more info on how to configure these options. *
  317. * *
  318. ***************************************************************************/
  319. custom: {
  320. baseUrl: 'https://example.com',
  321. internalEmailAddress: 'support@example.com',
  322. // mailgunDomain: 'mg.example.com',
  323. // mailgunSecret: 'key-prod_fake_bd32301385130a0bafe030c',
  324. // stripeSecret: 'sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm',
  325. //--------------------------------------------------------------------------
  326. // /\ OR, to avoid checking them in to version control, you might opt to
  327. // || set sensitive credentials like these using environment variables.
  328. //
  329. // For example:
  330. // ```
  331. // sails_custom__mailgunDomain=mg.example.com
  332. // sails_custom__mailgunSecret=key-prod_fake_bd32301385130a0bafe030c
  333. // sails_custom__stripeSecret=sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm
  334. // ```
  335. //--------------------------------------------------------------------------
  336. },
  337. };