Express Framework Common settings

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.