next-ssl-redirect-middleware
Version:
Nextjs Middleware to redirect http to https
28 lines (15 loc) • 819 B
Markdown
[](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).
`npm i -S next-ssl-redirect-middleware`
Create a file `middleware.ts` (or `.js`) with the following:
```typescript
import sslRedirect from 'next-ssl-redirect-middleware';
export default sslRedirect({});
```
- `environments`: List of `NODE_ENV` to run this middleware for. Defaults `['production']`
- `status`: The status code to redirect with. defaults to `301`
[](https://github.com/paulomcnally/node-heroku-ssl-redirect) was referenced heavily in the creation of this library.