# next-ssl-redirect-middleware

> Nextjs Middleware to redirect http to https

Latest version **0.1.5** (published 2023-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install next-ssl-redirect-middleware
pnpm add next-ssl-redirect-middleware
yarn add next-ssl-redirect-middleware
bun add next-ssl-redirect-middleware
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2023-08-28 |
| First published | 2021-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Charlie Jonas |
| Maintainers | cjonas |
| Keywords | nextjs, ssl, redirect, heroku |

## Links

- npm: https://www.npmjs.com/package/next-ssl-redirect-middleware
- Repository: https://github.com/ChuckJonas/next-ssl-redirect-middleware
- Homepage: https://github.com/ChuckJonas/next-ssl-redirect-middleware#readme
- Issues: https://github.com/ChuckJonas/next-ssl-redirect-middleware/issues
- npm.io page: https://npm.io/package/next-ssl-redirect-middleware

## Recent versions

- 0.1.5 (latest) — 2023-08-28
- 0.1.4 — 2022-07-27
- 0.1.3 — 2021-12-11
- 0.1.2 — 2021-12-11
- 0.1.1 — 2021-12-11
- 0.1.0 — 2021-12-11
- 0.0.4 — 2021-12-11
- 0.0.3 — 2021-12-11
- 0.0.2 — 2021-12-11
- 0.0.1 — 2021-12-11

## README

# next-ssl-redirect-middleware

[Nextjs Middleware](https://nextjs.org/docs/middleware) to redirect `http` to `https`.  This is helpful if you are hosting your site on a service that doesn't have "force ssl" support out of the box (IE: heroku).

## Install 

`npm i -S next-ssl-redirect-middleware`

## Usage

Create a file `middleware.ts` (or `.js`) with the following:

```typescript
import sslRedirect from 'next-ssl-redirect-middleware';

export default sslRedirect({});
```

### Options:

- `environments`: List of `NODE_ENV` to run this middleware for.  Defaults `['production']`

- `status`: The status code to redirect with.  defaults to `301`

## Credits

[paulomcnally/node-heroku-ssl-redirect](https://github.com/paulomcnally/node-heroku-ssl-redirect) was referenced heavily in the creation of this library.

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