# koa-ssl

> Enforce SSL for koa apps

Latest version **2.0.1** (published 2018-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-ssl
pnpm add koa-ssl
yarn add koa-ssl
bun add koa-ssl
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2018-08-10 |
| First published | 2014-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 7.4.0 |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Jonathan Clem |
| Maintainers | jclem |
| Keywords | ssl, koa |

## Links

- npm: https://www.npmjs.com/package/koa-ssl
- Repository: https://github.com/jclem/koa-ssl
- Issues: https://github.com/jclem/koa-ssl/issues
- npm.io page: https://npm.io/package/koa-ssl

## Recent versions

- 2.0.1 (latest) — 2018-08-10
- 2.0.0 — 2015-02-16
- 1.0.1 — 2014-04-18
- 1.0.0 — 2014-04-18

## README

# koa-ssl

[![Circle CI](https://circleci.com/gh/jclem/koa-ssl.svg?style=svg)](https://circleci.com/gh/jclem/koa-ssl)

koa-ssl enforces SSL for [Koa][koa] apps.

## Use

Simply require and use the function exported by this module:

```javascript
var ssl = require('koa-ssl');
var app = require('koa')();
app.use(ssl());
```

The function takes an optional object of options:

- `disabled`: (default `false`) If `true`, this middleware will allow all
requests through.
- `trustProxy`: (default `false`) If `true`, trust the `x-forwarded-proto`
header. If it is "https", requests are allowed through.
- `disallow`: A non-Generator function called with the Koa context so that the
user can handle rejecting non-SSL requests themselves.

By default, this middleware will only run when `process.env.NODE_ENV` is set to
"production". Unless a `disallow` function is supplied it will respond with the
status code 403 and the body "Please use HTTPS when communicating with this
server."

## Thanks, Heroku

While I created and maintain this project, it was done while I was an employee
of [Heroku][heroku] on the Human Interfaces Team, and they were kind enough to
allow me to open source the work. Heroku is awesome.

[heroku]: https://www.heroku.com/home
[koa]: https://github.com/koajs/koa

---
_Source: https://npm.io/package/koa-ssl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
