New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

testing-https-server

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testing-https-server

A simple HTTPS static file server with built-in self-signed certificates for testing purposes. Similar to http-server but provides HTTPS functionality out of the box.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

HTTPS Server

A simple HTTPS static file server with built-in self-signed certificates for testing purposes. Similar to http-server but provides HTTPS functionality out of the box.

Features

  • 🔒 Built-in HTTPS: Self-signed certificates included for immediate testing
  • 📁 Static File Serving: Serves any directory with automatic index.html detection
  • 🌐 CORS Support: Enable/disable CORS headers as needed
  • 💾 Caching Control: Configurable cache headers
  • 🎨 Colored Output: Beautiful console output with status information
  • 🚀 SPA Support: Fallback to index.html for single-page applications
  • 🛑 Graceful Shutdown: Clean server shutdown on SIGINT/SIGTERM

Installation

npm install

Usage

Command Line

# Serve current directory on default port (8443)
npx https-server

# Serve specific directory
npx https-server ./public

# Custom port
npx https-server -p 9000

# Enable caching for 1 hour
npx https-server -c 3600

# Disable CORS
npx https-server --no-cors

# Bind to different address
npx https-server -a 0.0.0.0

# Silent mode (minimal output)
npx https-server -s

# Open browser automatically (requires 'opener' package)
npx https-server -o

Programmatic Usage

const HttpsServer = require('./index');

const server = new HttpsServer({
  port: 8443,
  directory: './public',
  host: 'localhost',
  cors: true,
  cache: 3600
});

server.start()
  .then(() => {
    console.log('Server started successfully!');
  })
  .catch((err) => {
    console.error('Failed to start server:', err);
  });

Options

OptionShortDefaultDescription
--port-p8443Port to listen on
--address-alocalhostAddress to bind to
--cache-c-1Cache time in seconds (-1 disables caching)
--no-corsDisable CORS headers
--open-oOpen browser after starting
--silent-sSuppress log messages
--help-hShow help information

Security Warning

⚠️ Important: This server uses self-signed certificates for testing purposes only.

When you visit https://localhost:8443 (or your chosen port), your browser will show a security warning. This is expected behavior. To proceed:

  • Click "Advanced" (Chrome) or "Advanced..." (Firefox)
  • Click "Proceed to localhost (unsafe)" or "Accept the Risk and Continue"

Never use these certificates in production!

Examples

Basic Static Site

# Create some test files
mkdir my-site
echo '<h1>Hello HTTPS!</h1>' > my-site/index.html
echo '<h2>About Page</h2>' > my-site/about.html

# Serve the site
npx https-server my-site

# Visit https://localhost:8443

Single Page Application

# For SPAs, all routes will fallback to index.html
npx https-server ./dist

# Perfect for React, Vue, Angular apps

Development with Hot Reload

# Enable caching for assets but not HTML
npx https-server -c 0 ./build

Public Access

# Bind to all interfaces (be careful!)
npx https-server -a 0.0.0.0 -p 8443

API Reference

HttpsServer Class

Constructor Options

{
  port: 8443,           // Port number
  directory: '.',       // Directory to serve
  host: 'localhost',    // Host to bind to
  cors: true,           // Enable CORS headers
  cache: -1             // Cache time in seconds (-1 = no cache)
}

Methods

  • start() - Returns a Promise that resolves when server starts
  • stop() - Returns a Promise that resolves when server stops gracefully

Troubleshooting

Port Already in Use

# Check what's using the port
npx https-server -p 9000

Permission Denied (Ports < 1024)

# Use a port > 1024 or run with sudo (not recommended)
npx https-server -p 8443

Browser Won't Accept Certificate

  • Try in incognito/private browsing mode
  • Clear browser cache and cookies
  • Make sure you're accessing via https:// not http://

License

MIT

Contributing

  • Fork the repository
  • Create your feature branch
  • Commit your changes
  • Push to the branch
  • Create a Pull Request

Happy serving! 🚀

Keywords

https

FAQs

Package last updated on 23 Sep 2025

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