{"id":19153236,"url":"https://github.com/fatalxiao/http-proxy-middleware-body","last_synced_at":"2025-04-14T18:09:37.530Z","repository":{"id":57145430,"uuid":"300827744","full_name":"fatalxiao/http-proxy-middleware-body","owner":"fatalxiao","description":"Get response body when using http-proxy-middleware.","archived":false,"fork":false,"pushed_at":"2023-07-14T02:07:15.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T18:09:34.044Z","etag":null,"topics":["http-proxy-middleware"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fatalxiao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-03T07:58:57.000Z","updated_at":"2024-06-29T16:34:58.000Z","dependencies_parsed_at":"2024-11-09T08:34:56.866Z","dependency_job_id":null,"html_url":"https://github.com/fatalxiao/http-proxy-middleware-body","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatalxiao%2Fhttp-proxy-middleware-body","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatalxiao%2Fhttp-proxy-middleware-body/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatalxiao%2Fhttp-proxy-middleware-body/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatalxiao%2Fhttp-proxy-middleware-body/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fatalxiao","download_url":"https://codeload.github.com/fatalxiao/http-proxy-middleware-body/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933340,"owners_count":21185460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http-proxy-middleware"],"created_at":"2024-11-09T08:22:23.853Z","updated_at":"2025-04-14T18:09:37.494Z","avatar_url":"https://github.com/fatalxiao.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# http-proxy-middleware-body\n\n[![NPM Version][npm-image]][npm-url]\n[![License][license-image]][npm-url]\n\n[npm-image]: https://img.shields.io/npm/v/http-proxy-middleware-body.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/http-proxy-middleware-body\n[license-image]: https://img.shields.io/npm/l/http-proxy-middleware-body.svg?style=flat-square\n\nGet response body when using `http-proxy-middleware`.\n\n## Example\n\nAn example with `express` server.\n\n```javascript\nconst express = require('express'),\n    {createProxyMiddleware} = require('http-proxy-middleware'),\n    getBody = require('http-proxy-middleware-body'),\n\n    app = express();\n\napp.use(createProxyMiddleware('SOME_CONTEXT', {\n\n    // other configs...\n\n    onProxyRes: (proxyRes, req, res) =\u003e getBody(res, proxyRes, rawBody =\u003e {\n\n        if (!rawBody) {\n            return;\n        }\n\n        try {\n\n            // if it's a json body\n            const body = JSON.parse(rawBody);\n\n            // token expired\n            if (body.code === 'TOKEN_EXPIRED_CODE') {\n                // remove token...\n            }\n\n        } catch (e) {\n            // do something...\n        }\n\n    })\n\n}));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatalxiao%2Fhttp-proxy-middleware-body","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffatalxiao%2Fhttp-proxy-middleware-body","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatalxiao%2Fhttp-proxy-middleware-body/lists"}