koa-www-authenticate

Add WWW-Authenticate header on 401 errors

Usage no npm install needed!

<script type="module">
  import koaWwwAuthenticate from 'https://cdn.skypack.dev/koa-www-authenticate';
</script>

README

koa-www-authenticate

Add WWW-Authenticate header on 401 errors

Usage

wwwAuthenticate = require('koa-www-authenticate');
app.use(wwwAuthenticate({
    realm: 'foo',
    scheme: 'Basic'
}));
app.use(function *(next) {
    this.throw(401, "Test www-authenticate");
});

// Response will have 'WWW-Authenticate' header set to 'Basic realm="foo"'