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 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack-symmetric

v1.0.13

Published

Webpack dev server configurations for running a proxy to a backend including self-signed certs.

Downloads

2

Readme

About

This package exposes a single function createBackendProxy({...}) which will generate a proxy configuration and self-signed certs.

Usage

The generated proxy configuration will do the following things:

  • Create request/response handlers that route to the backend any path starting with anything from options.paths or any second-level path from options.subpaths.
  • Reset sessionid cookies when switching between projects.
  • Generate a self-signed root cert and add it as trusted to your keychain. So no browser warnings should ever popup.
  • Generate a root signed cert used in the proxy, which includes standard alternate names of localhost, <host>.local, 127.0.0.1, any other detected interface ips, and your externally facing ip.

NOTE: SSL cert generation only happens when webpack is run as webpack-dev-server

The root CA cert

In order to avoid warnings in your browser make sure that the root CA cert is installed as a trusted root cert in your system after the first time running webpack server. This only needs to be done once and not repeated for every project. On OSX this is done automatically but look for a console message on other systems.

Installing the root CA cert on other devices

See certServer setting below and follow the instructions on the installation page.

createBackendProxy options

The only required option is backend, everything else is optional.

  • backend - The backend origin to proxy to
  • paths - The first-level URL paths to match and proxy to the backend
  • subpaths - The second-level URL paths to match and proxy to the backend
  • originRewrites - Array of origins to localize as relative paths instead when found under src or href attributes in a proxied response
  • insecure - If true run the server as http instead of self-signed https
  • generateCert - If true will force the certificate to be generated outside of a webpack-dev-server invocations
  • certServer - If true will run a separate http server on port 3007 with instructions on installing the root cert on other devices
  • ssl.additionalDomains - Additional domain names to add as alternate names allowed with the SSL cert
  • ssl.additionalIPs - Additional IP addresses to add as alternate names allowed with the SSL cert
  • ssl.home - Root directory used to store all generated certs and keys. Defaults to ~/.symmetric

Environment variables

  • CERT_SERVER=true - Can be used instead of the certServer option
  • GENERATE_CERT=true - Can be used in place of the generateCert option
  • SYMMETRIC_HOME - Can be used instead of the ssl.home option

Setting up devServer in webpack

Add the following settings to your webpack devServer configuration object to get the proxy going.

First generate a proxy configuration using proxy = createBackendProxy({...}). Within your devServer object:

  • Set proxy: { '/': proxy } for the most basic setup off the root URL path
  • If running with SSL, set https: proxy.ssl
  • Optionally, set host: '0.0.0.0' to allow any remote connection in not just from localhost, needed if running inside a VM
  • Optionally, to allow connections to mDBS .local hostnames, set allowedHosts: ['localhost', '.local']

License

MIT