Bearer plugin
Plugin for elysia for retrieving the Bearer token.
Install with:
bun add @elysia/bearer@nextThen use it:
import { Elysia } from 'elysia'import { bearer } from '@elysia/bearer'
const app = new Elysia() .use(bearer()) .get('/sign', { beforeHandle({ bearer, set, status }) { if (!bearer) { set.headers[ 'WWW-Authenticate' ] = `Bearer realm="sign"`
return status(401, 'Unauthorized') } } }, ({ bearer }) => bearer) .listen(3000)This plugin is for retrieving a Bearer token specified in RFC6750.
This plugin extracts the token. It does not authenticate the request or validate the token; add those checks in your application.