Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-https

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-https

This is a simple HTTPS proxy to be used with Next.js in local development.

  • 1.1.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
167
decreased by-42.01%
Maintainers
1
Weekly downloads
 
Created
Source

next-https

This is a simple HTTPS proxy to be used with Next.js in local development.

Motivation

A secure HTTP connection is necessary when interfacing with certain Web APIs restricted to secure contexts. This package simply starts an HTTP proxy pointing at your Next.js server instance to simplify local development.

Getting Started

Install the package

yarn add next-https

Inside your Next.js configuration file:

// next.config.js
const useHttps = require("next-https");

// You can pass options here
const withHttps = useHttps({
  enabled: process.env.NODE_ENV === "development",
});

// pass your Next.js options here
module.exports = withHttps({
  reactStrictMode: true,
});

NOTE: When using the default configuration options, you'll have to accept the self-signed certificate the first time you access the page. This is safe to do in a local development environment only.

Configuration

You can use next-https with default configuration options.

namerequireddescription
enablednoDefaults to process.env.NODE_ENV === 'development'
hostnoNext.js server hostname, defaults to localhost
targetnoNext.js port target, defaults to 3000
keynoPath to the key, defaults to this package's key file
certnoPath to the certificate, defaults to this package's cert file

Using custom certificates

If you want to use a custom domain name or to remove the initial warning from your browser, you'll need to setup your own certificates.

To avoid the warnings you need to install the local root CA in your computer in order for your browser to trust the certificates.

For this you can use mkcert

brew install mkcert

Install the local CA

mkcert -install

Create the certificate files

mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1

And pass your custom certificate and key

// next.config.js
const nextHttps = require("next-https");

// You can pass options here
const withHttps = nextHttps({
  host: "example.com",
  key: './path/to/example-key.pem'),
  cert: './path/to/example-cert.pem'),
});

// pass your Next.js options here
module.exports = withHttps({
  reactStrictMode: true,
});

Keywords

FAQs

Package last updated on 01 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc