Stable Release in branch 3.x
3.21.2
Released 31 Jul 2015
(10 years ago)
SoftwareExpress
Version3.x
Minimum
Node.js version
Node.js 0.8.0+
Initial release3.0.1
01 Nov 2012
(13 years ago)
Latest release3.21.2
31 Jul 2015
(10 years ago)
End of support (OSS)Jul 2015
(Ended 10 years ago)
Commercial support
(HeroDevs-NES)
Yes
Release noteshttps://github.com/expressjs/express/releases/tag/3.21.2
Source codehttps://github.com/expressjs/express/tree/3.21.2
Downloadhttps://github.com/expressjs/express/releases/tag/3.21.2
Express 3.x ReleasesView full list

What Is New in Express 3

CategoryFeature
New Featureapp.head() support
New Featureapp.locals and app.locals(obj)
New Featureapp.render and app.engine for view handling
Improvementtrust proxy setting for X-Forwarded-Proto and X-Forwarded-For
Improvementjson spaces and json replacer settings for res.json()
New FeatureRequest helpers: req.path, req.protocol, req.get, req.accepts*, req.accepted*, req.signedCookies, req.stale/fresh, req.ips, req.ip, req.range
New FeatureResponse helpers: res.get, res.set, res.type, res.format, res.locals, res.redirect relative, res.links, res.jsonp, JSON and signed cookie support
New Featureexpress.application, express.request, express.response prototypes

How does Express 3 handle proxy headers and HTTPS detection?

Express 3 adds a trust proxy setting that makes req.protocol and res.redirect respect the X-Forwarded-Proto and X-Forwarded-For headers.

app.set('trust proxy', true);
app.get('/', function (req, res) {
  // req.protocol will be 'https' if X-Forwarded-Proto is 'https'
  res.send('Protocol: ' + req.protocol);
});

When the flag is on, req.ip also falls back to the first entry in req.ips, giving you the real client address behind a load balancer.

What new request helpers does Express 3 provide?

Express 3 ships with a richer req object that covers routing, content negotiation, caching and range parsing out of the box.

HelperWhat it gives you
req.paththe URL pathname without query string
req.protocol"http" or "https", respects trust proxy
req.get(field)shortcut for req.headers[field.toLowerCase()]
req.accepts(...types)returns the best match based on the Accept header
req.acceptedsorted array of accepted media types
req.acceptsCharset(...)negotiates character sets
req.acceptsLanguage(...)negotiates languages
req.signedCookiesobject of cookies that were signed with the secret
req.stale / req.freshcache-validation helpers based on ETag/Last-Modified
req.ips & req.iparray of forwarded IPs and the first client IP
req.range(size)parses the Range header into start/end pairs

These helpers cut down on boilerplate; you no longer need external modules for basic content-negotiation or IP extraction.

How can I simplify response handling with Express 3's new methods?

Express 3 adds a suite of res utilities that let you set headers, negotiate content, and manage cookies without reaching for third-party libraries.

app.get('/data', function (req, res) {
  res.type('json');
  res.format({
    json: function () { res.json({ ok: true }); },
    html: function () { res.send('<h1>OK</h1>'); }
  });
});

Use res.locals to stash view data, res.links to emit RFC-5988 Link headers, and res.jsonp for explicit JSONP callbacks. Cookie handling now accepts objects directly, and signed cookies are a one-liner with { signed: true }.

Why should I use app.locals and res.locals in Express 3?

app.locals and res.locals give you a clean, template-friendly namespace that lives outside the request cycle.

Set global values once on the app:

app.locals.siteName = 'Acme Corp';

Then add request-specific data in a route:

app.get('/', function (req, res) {
  res.locals.user = req.user;
  res.render('home');
});

This avoids mutating req and keeps your view layer decoupled from middleware concerns.

Common Questions

Does enabling trust proxy affect how req.ip is calculated?
Yes, with trust proxy on, req.ip returns the first address in the X-Forwarded-For header instead of the direct socket address.

How do I set multiple response headers at once?
You can pass an object to res.set, e.g., res.set({ 'Cache-Control': 'no-cache', 'X-Powered-By': 'Express' }).

Can I render a view without attaching a route handler?
Yes, app.render lets you invoke a view directly from any part of your code, returning the HTML via a callback.

What is the difference between res.type and res.contentType?
res.type is an alias for res.contentType; both set the Content-Type header based on the given mime or extension.

How do I send pretty-printed JSON in production?
Set app.set('json spaces', 2) to have res.json format its output with two-space indentation.

Releases In Branch 3.x

VersionRelease date
3.21.231 Jul 2015
(10 years ago)
3.21.106 Jul 2015
(10 years ago)
3.21.018 Jun 2015
(11 years ago)
3.20.318 May 2015
(11 years ago)
3.20.217 Mar 2015
(11 years ago)
3.20.128 Feb 2015
(11 years ago)
3.20.018 Feb 2015
(11 years ago)
3.19.201 Feb 2015
(11 years ago)
3.19.121 Jan 2015
(11 years ago)
3.19.009 Jan 2015
(11 years ago)
3.18.612 Dec 2014
(11 years ago)
3.18.511 Dec 2014
(11 years ago)
3.18.423 Nov 2014
(11 years ago)
3.18.309 Nov 2014
(11 years ago)
3.18.229 Oct 2014
(11 years ago)
3.18.123 Oct 2014
(11 years ago)
3.18.018 Oct 2014
(11 years ago)
3.17.816 Oct 2014
(11 years ago)
3.17.708 Oct 2014
(11 years ago)
3.17.602 Oct 2014
(11 years ago)
3.17.524 Sep 2014
(11 years ago)
3.17.419 Sep 2014
(11 years ago)
3.17.318 Sep 2014
(11 years ago)
3.17.216 Sep 2014
(11 years ago)
3.17.008 Sep 2014
(11 years ago)
3.17.108 Sep 2014
(11 years ago)
3.16.1005 Sep 2014
(11 years ago)
3.16.930 Aug 2014
(11 years ago)
3.16.827 Aug 2014
(11 years ago)
3.16.718 Aug 2014
(11 years ago)
3.16.614 Aug 2014
(11 years ago)
3.16.511 Aug 2014
(11 years ago)
3.16.410 Aug 2014
(11 years ago)
3.16.207 Aug 2014
(11 years ago)
3.16.307 Aug 2014
(11 years ago)
3.16.006 Aug 2014
(11 years ago)
3.16.106 Aug 2014
(11 years ago)
3.15.304 Aug 2014
(11 years ago)
3.15.227 Jul 2014
(11 years ago)
3.15.126 Jul 2014
(11 years ago)
3.15.023 Jul 2014
(11 years ago)
3.14.011 Jul 2014
(11 years ago)
3.13.004 Jul 2014
(11 years ago)
3.12.126 Jun 2014
(11 years ago)
3.12.021 Jun 2014
(12 years ago)
3.11.019 Jun 2014
(12 years ago)
3.10.512 Jun 2014
(12 years ago)
3.10.409 Jun 2014
(12 years ago)
3.10.305 Jun 2014
(12 years ago)
3.10.003 Jun 2014
(12 years ago)
3.10.103 Jun 2014
(12 years ago)
3.10.203 Jun 2014
(12 years ago)
3.9.030 May 2014
(12 years ago)
3.8.127 May 2014
(12 years ago)
3.8.021 May 2014
(12 years ago)
3.7.018 May 2014
(12 years ago)
3.6.009 May 2014
(12 years ago)
3.5.308 May 2014
(12 years ago)
3.5.224 Apr 2014
(12 years ago)
3.5.125 Mar 2014
(12 years ago)
3.5.006 Mar 2014
(12 years ago)
3.4.813 Jan 2014
(12 years ago)
3.4.710 Dec 2013
(12 years ago)
3.4.601 Dec 2013
(12 years ago)
3.4.527 Nov 2013
(12 years ago)
3.4.429 Oct 2013
(12 years ago)
3.4.323 Oct 2013
(12 years ago)
3.4.218 Oct 2013
(12 years ago)
3.4.115 Oct 2013
(12 years ago)
3.4.007 Sep 2013
(12 years ago)
3.3.802 Sep 2013
(12 years ago)
3.3.728 Aug 2013
(12 years ago)
3.3.627 Aug 2013
(12 years ago)
3.3.511 Aug 2013
(12 years ago)
3.3.408 Jul 2013
(12 years ago)
3.3.304 Jul 2013
(12 years ago)
3.3.203 Jul 2013
(12 years ago)
3.3.127 Jun 2013
(12 years ago)
3.3.026 Jun 2013
(12 years ago)
3.2.602 Jun 2013
(13 years ago)
3.2.521 May 2013
(13 years ago)
3.2.409 May 2013
(13 years ago)
3.2.307 May 2013
(13 years ago)
3.2.203 May 2013
(13 years ago)
3.2.129 Apr 2013
(13 years ago)
3.2.015 Apr 2013
(13 years ago)
3.1.212 Apr 2013
(13 years ago)
3.1.101 Apr 2013
(13 years ago)
3.1.025 Jan 2013
(13 years ago)
3.0.604 Jan 2013
(13 years ago)
3.0.519 Dec 2012
(13 years ago)
3.0.405 Dec 2012
(13 years ago)
3.0.313 Nov 2012
(13 years ago)
3.0.208 Nov 2012
(13 years ago)
3.0.101 Nov 2012
(13 years ago)
3.0.0rc313 Aug 2012
(13 years ago)
3.0.0rc203 Aug 2012
(13 years ago)
3.0.0rc124 Jul 2012
(13 years ago)
3.0.0beta716 Jul 2012
(13 years ago)
3.0.0beta613 Jul 2012
(13 years ago)
3.0.0beta503 Jul 2012
(13 years ago)
3.0.0beta425 Jun 2012
(13 years ago)
3.0.0beta315 Jun 2012
(14 years ago)
3.0.0beta206 Jun 2012
(14 years ago)
3.0.0beta101 Jun 2012
(14 years ago)
3.0.0alpha530 May 2012
(14 years ago)
3.0.0alpha409 May 2012
(14 years ago)
3.0.0alpha304 May 2012
(14 years ago)
3.0.0alpha226 Apr 2012
(14 years ago)
3.0.0alpha115 Apr 2012
(14 years ago)