Express req.get() Method

Beginner
⏱️ 8 min read
📚 Updated: May 2026
🎯 4 Code Examples

What you’ll learn

  • How to read request headers using req.get().
  • How to access common headers like Authorization and Content-Type.
  • What req.get() returns for missing headers.
  • How to avoid header-parsing mistakes in middleware.

Usage syntax

javascript
req.get(field)
req.header(field)
1

Read Authorization header

javascript
app.get('/secure', function (req, res) {
  var auth = req.get('Authorization');
  if (!auth) return res.status(401).send('Missing Authorization header');
  res.send('Authorization header received');
});
2

Validate Content-Type header

javascript
app.post('/api/data', function (req, res) {
  var contentType = req.get('Content-Type') || '';
  if (contentType.indexOf('application/json') !== 0) {
    return res.status(415).send('Unsupported Media Type');
  }
  res.send('Valid content type');
});

❓ FAQ

It reads a specific incoming HTTP request header value by name.
No. req.get() header name matching is case-insensitive.
req.get() returns undefined when the requested header is not present.
Yes. req.header() is an alias of req.get() in Express.
Yes. It is commonly used to read Authorization, Content-Type, and custom headers.
Did you know?

req.get(headerName) is case-insensitive and returns the value of a request header or undefined if missing.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

4 people found this page helpful