Skip to content
This repository was archived by the owner on Jul 21, 2026. It is now read-only.

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

micro-hostname

Adapted the express.js algorithm to a micro middleware.

Installation

$ npm install micro-hostname

Example

import hostname from "micro-hostname"

export default hostname(
  async (req, res) => {
    console.log(req.hostname) // -> "localhost", or "my-deploy.now.sh", etc
  },
  {
    trustProxy: true
    // (Optional - default `false`) Whether to trust the X-Forwarded-Host if
    // you use a reverse proxy. You can also pass a function that accepts
    // `req.connection.remoteAddress` and returns a boolean whether to trust
    // it.
  }
)

If you don't use a bundler or ES module, you can import like

const hostname = require("micro-hostname").default

About

Micro middleware to get the hostname of the request

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages