View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page


Configuration for your app's underlying HTTP server. These properties are conventionally specified in the config/http.js configuration file.


Property Type Default Details
middleware See conventional defaults for HTTP middleware A dictionary of all HTTP middleware functions your app will run on every incoming HTTP request.
middleware.order See conventional defaults for HTTP middleware order An array of middleware names (strings) indicating the order in which middleware should be run for all incoming HTTP requests.
cache cache: 31557600000 (1 year) The number of milliseconds to cache static assets when your app is running in a 'production' environment.
These are any flat files like images, scripts, stylesheets, etc. that are served by Express' static middleware (by default, these files are served from .tmp/public, a hidden folder compiled by Grunt).
serverOptions {} SSL only: options to send directly to the Node https module when creating the server. These will be merged with your SSL settings, if any. See the createServer docs for more info.


Most middleware compatible with Express, Connect, Kraken, Loopback, or Pillar can also be used in a Sails app.


  • Note that this HTTP middleware stack configured in sails.config.http.middleware is only applied to true HTTP requests-- it is ignored when handling virtual requests (e.g. sockets)
  • The middleware named router is what handles all of your app's explicit routes (i.e. sails.config.routes) as well as shadow routes that are injected for blueprints, policies, etc.
  • You cannot define a custom middleware function with the key order (since sails.config.http.middleware.order has special meaning)

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.


We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book