sails.config.http
Configuration for your app's underlying HTTP server. These properties are conventionally specified in the config/http.js
configuration file.
Properties
Property | Type | Default | Details |
---|---|---|---|
middleware |
((object)) | See conventional defaults for HTTP middleware | A configuration object of all HTTP middleware functions your app will run on every incoming HTTP request. All Express or Connect middleware is supported. Example |
middleware.order |
((array)) | See conventional defaults for HTTP middleware order | The order in which middleware should be run for HTTP request (the Sails router, which runs the appropriate explicit routes, policies, controllers, etc. from your app is invoked by the "router" middleware). |
cache |
((number)) | cache: 31557600000 |
The number of milliseconds to cache flat files on disk being served by Express static middleware (by default, these files are in .tmp/public )The HTTP static cache is only active in a 'production' environment (default 1 year), since that's the only time Express will cache flat-files. |
serverOptions |
((object)) | TODO | TODO |
Notes
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)You cannot define a custom middleware function with the key
order
(sincesails.config.http.middleware.order
has special meaning)