npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

localhost-https

v2.0.1

Published

A secure and convenient solution for enabling HTTPS on localhost

Downloads

47

Readme

Localhost Cert / Localhost Https

一个安全、便捷的 localhost 支持 HTTPS 的方案

English

什么时候使用 Localhost Cert?

如果你在启动本地开发服务器时需要开启 https,那么 Localhost Cert 就是你需要的工具。它可以快速获取已经生成的证书。

是否需要安装根证书?

和大多数代理工具一样,你仍然需要安装根证书。这是因为 Localhost Cert 使用了自签名证书,而浏览器默认不信任自签名证书。虽然在你本地安装了根证书,但是这是绝对安全的。

为什么推荐团队一起使用?

  • 当团队成员统一使用 localhost-cert,启动本地服务器时可共享同一套 HTTPS 证书配置,无需为不同项目或成员重复生成。
  • 如果你在维护开源项目,采用这种方式可以让所有参与者共享同一个根证书,降低协作成本。
  • 如果你想新增域名或内网 IP 到 SAN 列表,欢迎提交 issue 或 PR,让更多人一起受益。

当前默认支持的域名与 IP

  • DNS 名称:localhost*.localhostlocalhost.localdomaindev.local*.dev.local*.local*.localdomain*.test*.home*.internal*.lanhost.docker.internal*.docker.internal 等常见开发域名。
  • 回环与典型内网地址:127.0.0.1127.0.1.110.0.0.110.1.1.1172.16.0.1172.17.0.1172.30.0.1172.31.0.1192.168.10.1
  • 批量 IP 覆盖:完整包含 192.168.0.x192.168.1.x192.168.3.x 三段网段(即 192.168.{0,1,3}.1-255)。

这样的取舍既保证常见开发场景可用,也避免了证书过大导致浏览器或系统拒绝。如果你还需要额外的域名或 IP,欢迎通过 issue 或 PR 反馈,我们会评估后逐步扩充。

为什么是安全的?

如果你对 HTTPS 有一定的了解,那么你应该知道如果在本地安装一个 CA 根证书,这是一个很危险的事,因为这个根证书可以用于签名任何域名比如,google.com. 从而达到中间人劫持,但是 Localhost Cert 生成 localhost 的域名后,立马丢弃了根证书的私钥,也就是说,即便有人想用这个根证书对其他网站签名是不可能的。 那么是如何保证私钥没有被记住呢,Localhost cert 是利用 github action 生成根证书的,github Action 生成的过程以及 github 当时的代码是完全可追踪的,如果感兴趣可以查看github action

总结一下基于两点,它是完全安全的 1、生成根证书的过程是基于 github action,是完全可追踪的 2、签名 localhost 域名后,根证书私钥被丢弃了,无法用于签名其他域名

如何使用?

npm install localhost-cert --save-dev

wevpack-dev-server

const getHttps = require('localhost-cert');

// webpack config
module.exports = {
    devServer: {
        https: getHttps(),
    },
};
// vite config
const getHttps = require('localhost-cert');
export default defineConfig({
    server: {
        https: getHttps({
            // 如果开发者没有安装根证书,那么会引导开发者安装根证书.
            autoInstall: true,
        }),
    },
});

License

Localhost Cert is licensed under the MIT License.