Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-proxy-middleware-body

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-proxy-middleware-body

Get response body for http-proxy-middleware

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

http-proxy-middleware-body

NPM Version License

Get response body when using http-proxy-middleware.

Example

An example with express server.

const express = require('express'),
    {createProxyMiddleware} = require('http-proxy-middleware'),
    getBody = require('http-proxy-middleware-body'),

    app = express();

app.use(createProxyMiddleware('SOME_CONTEXT', {

    // other configs...

    onProxyRes: (proxyRes, req, res) => getBody(res, proxyRes, rawBody => {

        if (!rawBody) {
            return;
        }

        try {

            // if it's a json body
            const body = JSON.parse(rawBody);

            // token expired
            if (body.code === 'TOKEN_EXPIRED_CODE') {
                // remove token...
            }

        } catch (e) {
            // do something...
        }

    })

}));

Keywords

FAQs

Package last updated on 14 Jul 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc