ExpressSet System Settings
1. no need to redefine , most have default values, do not set
2. Common Settings
ü env
ü View Cache
ü View engine
ü views
ü Trust Proxy
ü JSONP callback Name
ü JSON replacer and JSON spaces
ü Case Sensitive routing
ü Strict routing
ü x-powered-by
ü ETag
ü Query Parser
ü subdomain offset
Env
1. Common VALUES (development\test\stage\preview\production)
2. Write Value
a) app.set (' env ', ' development ');
b) process.env.nove_env=development;
c) $NODE _env=development NODE app(recommended)
d) Set the node_env variable on the machine ( environment variable )
View Cache
1. for cached view templates for easy re-access
2. on a production environment, enabled by default.
View Engine
View template engine (Ejs\jade\handlebar , etc. ) , using the default Jade.
Views
App.set (' Views ', Path.join (__dirname, ' templates '))
use an absolute path where __dirname represents the absolute path to the directory where app.js resides.
Trust Proxy
use a reverse proxy server (such as Nginx\varnish) is enabled. Indicates that the x-forward-* request header is allowed to be trusted .
Not enabled by default.
JSONP Callback Name
1. two ways to resolve cross-domain access restrictions:
a) using JSONP
I. support only GET
& nbsp; Ii. support for older browsers (not supported Cors
III. May cause XSS attacks
b) Add "cross-domain access to resource share header "(CORS Headers) When the service responds( recommended )
I. support various HTTP requests
II. better handling of exceptions
III. restricted scope of access
2. The default value is callback
3. usage
a) Localhost:3000/jsonp?cb=updateview
JSON replacer and JSON spaces case sensitive routing strict routing x-powered-by etag
the ETag can be seen as a unique identifier of the server response content when a request is made through the browser. On re-access, if the ETag does not change, the cache is used and the server is no longer requested.
Query Parser subdomain offsetCustom Settings
1. need to define yourself
Express Framework Common settings