Neverending Plethora of Modules

    TypeScript icon, indicating that this package has built-in type declarations

    0.1.8 • Public • Published


    Securely make authenticated requests to a remote server inside Webpack Dev Server proxies.

    This library helps you create an http-proxy-middleware that securly makes proxy requests with cookies. It will prompt you to enter auth cookies at initial start or when authentication failed.

    Problem Statement

    Imagine you have an API backend and a totally separate frontend. The dev environment for the backend is very complex to setup so sometimes you'd prefer to let local frontend dev server make direct requests to the production services or some shared environment.

    Now the tricky thing is the production service may require authentication. You local proxy has to bear the authentication headers or cookies in order to make requests to the API service. This package allows you to more easily manage and securely store the credentials needed for making these requests.


    In webpack.config.js, add devServer proxy rules like below:

    const { secureCookiesProxy } = require('http-proxy-middleware-secure-cookies');
    module.exports = {
      // ...
      devServer: {
        // ...
        proxy: {
          // use the default options to proxy /api/* to*
          '/api/*': secureCookiesProxy(''),
          // different endpoints share the same account
          '/proxy/fiz': secureCookiesProxy({
            target: '',
            keychainAccount: '',
          '/proxy/buz': secureCookiesProxy({
            target: '',
            keychainAccount: '',
    module.exports = config;

    This will automatically proxy local requests for http://locahost:$PORT/proxy/* to If the server returns a 401 HTTP status code, the dev server will automatically prompt you to enter a cookie string, store it in file system or the system keychain (when available), then use the cookies to authenticate future requests.

    Secure Cookie Storage

    By default, the package will try to install node-keytar to store the cookies in system keychain, if for some reason the installation failed (e.g., libsecret not pre-installed on Linux), we will fallback to using local files. By default the local file used is ${process.cwd()}/.proxy-cookies/[keychainAccount]. You can change the storage directory with following code (not recommended):

    const os = require('os');
    const { setCookieDirectory } = require('http-proxy-middleware-secure-cookies/dist/storage');
    // change it to home directory so cookies can be shared across apps


    Pass options via secureCookieProxy(options).


    The MIT License.


    npm i http-proxy-middleware-secure-cookies

    DownloadsWeekly Downloads






    Unpacked Size

    36.6 kB

    Total Files


    Last publish


    • ktmud