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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-filter-proxy

v1.0.3

Published

Vite filter proxy plugin

Readme

vite-plugin-filter-proxy

Provide local proxy for Vite.

Install

node version: >=12.0.0

vite version: >=2.0.0

# if using npm
npm i vite-plugin-filter-proxy -D
# if using yarn
yarn add vite-plugin-filter-proxy -D

Run example

cd ./example
npm install
cd server
node index
cd ..
npm run dev

Usage

  • Config plugin in vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import filterProxy from "../dist";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    filterProxy({
      "/": {
        target: "http://localhost:3000",
        /*  filter: ((reqPath, req) => req.method === 'POST') */
      },
    }),
  ],
  server: {
    port: 3001,
  },
});

Module exports

  • filterProxyOptions
interface configOptions {
  target: string;
  filter?: (pathname: string, req: Request) => boolean;
  pathRewrite?:
    | {
        [regexp: string]: string;
      }
    | ((path: string, req: Request) => string)
    | ((path: string, req: Request) => Promise<string>);
  router?:
    | {
        [hostOrPath: string]: httpProxy.ServerOptions["target"];
      }
    | ((req: Request) => httpProxy.ServerOptions["target"])
    | ((req: Request) => Promise<httpProxy.ServerOptions["target"]>);
  forward?: ProxyTargetUrl | undefined;
  /** Object to be passed to http(s).request. */
  agent?: any;
  /** Object to be passed to https.createServer(). */
  ssl?: any;
  /** If you want to proxy websockets. */
  ws?: boolean | undefined;
  /** Adds x- forward headers. */
  xfwd?: boolean | undefined;
  /** Verify SSL certificate. */
  secure?: boolean | undefined;
  /** Explicitly specify if we are proxying to another proxy. */
  toProxy?: boolean | undefined;
  /** Specify whether you want to prepend the target's path to the proxy path. */
  prependPath?: boolean | undefined;
  /** Specify whether you want to ignore the proxy path of the incoming request. */
  ignorePath?: boolean | undefined;
  /** Local interface string to bind for outgoing connections. */
  localAddress?: string | undefined;
  /** Changes the origin of the host header to the target URL. */
  changeOrigin?: boolean | undefined;
  /** specify whether you want to keep letter case of response header key */
  preserveHeaderKeyCase?: boolean | undefined;
  /** Basic authentication i.e. 'user:password' to compute an Authorization header. */
  auth?: string | undefined;
  /** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
  hostRewrite?: string | undefined;
  /** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
  autoRewrite?: boolean | undefined;
  /** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
  protocolRewrite?: string | undefined;
  /** rewrites domain of set-cookie headers. */
  cookieDomainRewrite?:
    | false
    | string
    | { [oldDomain: string]: string }
    | undefined;
  /** rewrites path of set-cookie headers. Default: false */
  cookiePathRewrite?:
    | false
    | string
    | { [oldPath: string]: string }
    | undefined;
  /** object with extra headers to be added to target requests. */
  headers?: { [header: string]: string } | undefined;
  /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
  proxyTimeout?: number | undefined;
  /** Timeout (in milliseconds) for incoming requests */
  timeout?: number | undefined;
  /** Specify whether you want to follow redirects. Default: false */
  followRedirects?: boolean | undefined;
  /** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
  selfHandleResponse?: boolean | undefined;
  /** Buffer */
  buffer?: stream.Stream | undefined;
  logLevel?: "debug" | "info" | "warn" | "error" | "silent";
  logProvider?: LogProviderCallback;
  onError?: OnErrorCallback;
  onProxyRes?: OnProxyResCallback;
  onProxyReq?: OnProxyReqCallback;
  onProxyReqWs?: OnProxyReqWsCallback;
  onOpen?: OnOpenCallback;
  onClose?: OnCloseCallback;
}

interface options {
  [url: string]: configOptions;
}

filter proxy examples

  • all request proxy to port 3000
export default defineConfig({
  plugins: [
    vue(),
    filterProxy({
      "/": {
        target: "http://localhost:3000",
      },
    }),
  ],
  server: {
    port: 3001,
  },
});
  • only request methods "POST" proxy to port 3000
export default defineConfig({
  plugins: [
    vue(),
    filterProxy({
      "/": {
        target: "http://localhost:3000",
        filter: (reqPath, req) => req.method === "POST",
      },
    }),
  ],
  server: {
    port: 3001,
  },
});

License

MIT