- Notifications
You must be signed in to change notification settings - Fork 876
Closed
Description
Checks
- I understand project setup issues should be asked on StackOverflow or in GitHub Discussions.
- I updated to latest
http-proxy-middleware.
Describe the bug (be clear and concise)
web page continuously load when selfHandleResponse: true, used
Step-by-step reproduction instructions
const express = require('express'); const morgan = require("morgan"); const { createProxyMiddleware , responseInterceptor } = require('http-proxy-middleware'); // Create Express Server const app = express(); // Configuration const PORT = 3000; const HOST = "localhost"; const proxy = createProxyMiddleware({ target: 'http://example.com', changeOrigin: true, // for vhosted sites /** * IMPORTANT: avoid res.end being called automatically **/ selfHandleResponse: true, // res.end() will be called internally by responseInterceptor() /** * Intercept response and replace 'Hello' with 'Teapot' with 418 http response status code **/ on: { proxyRes: responseInterceptor(async (responseBuffer, proxyRes, req, res) => { res.statusCode = 418; // set different response status code const response = responseBuffer.toString('utf8'); return response.replace('Hello', 'Teapot'); }), }, }); app.get('/', proxy) // Start Proxy app.listen(PORT, HOST, () => { console.log(`Starting Proxy at http://${HOST}:${PORT}`); });Expected behavior (be clear and concise)
normally it loads when selfHandleResponse: false, but to edit response i need it to be true
How is http-proxy-middleware used in your project?
PS C:\Users\In-Motion\Desktop\netninja> npm ls http-proxy-middleware npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. netninja@1.0.0 C:\Users\In-Motion\Desktop\netninja └── http-proxy-middleware@2.0.6What http-proxy-middleware configuration are you using?
{ "dependencies": { "express": "^4.18.1", "http-proxy": "^1.18.1", "http-proxy-middleware": "^2.0.6", "morgan": "^1.10.0", "url": "^0.11.0" },What OS/version and node/version are you seeing the problem?
Windows 10 64 bitAdditional context (optional)
No response
Metadata
Metadata
Assignees
Labels
No labels