/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-routing-with-host-h-a65cdf42511a-routing-with-host-header-value-s0602-c0000.md
Routing with `host` Header value - hono-docs
Routing with host Header value Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt routing with host...
Routing with host Header value
Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#routing-with-host-header-value
Summary
Hono can handle the host header value if you set the getPath() function in the Hono constructor. ```ts twoslash import { Hono } from 'hono' // ---cut--- const app = new Hono({ getPath: (req) => '/' + req.headers.get('host') + req.url...
Content
Hono can handle the host header value if you set the getPath() function in the Hono constructor.
import { Hono } from 'hono'
// ---cut---
const app = new Hono({
getPath: (req) =>
'/' +
req.headers.get('host') +
req.url.replace(/^https?:\/\/[^/]+(\/[^?]*).*/, '$1'),
})
app.get('/www1.example.com/hello', (c) => c.text('hello www1'))
// A following request will match the route:
// new Request('http://www1.example.com/hello', {
// headers: { host: 'www1.example.com' },
// })By applying this, for example, you can change the routing by User-Agent header.