mirror of
https://github.com/honojs/hono.git
synced 2024-11-29 17:46:30 +01:00
.. | ||
index.ts | ||
README.md |
Bearer Auth Middleware
Usage
import { Hono } from 'hono'
import { bearerAuth } from 'hono/bearer-auth'
const app = new Hono()
const token = 'honoisacool'
app.use('/auth/*', bearerAuth({ token }))
app.get('/auth/page', (c) => {
return c.text('You are authorized')
})
app.fire()
Options
app.use(
'/auth/*',
bearerAuth({
token: 'honoisacool', // Required
realm: 'example.com',
prefix: 'Bot'
hashFunction: (d: string) => SHA256(d).toString(), // For Fastly Compute@Edge
})
)