We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onProxyReq
onProxyRes
I think it would be useful to add onProxyReq and onProxyRes options in the constructor function:
httpProxyMiddleware(req, res, { // You can use the `http-proxy` option target: 'https://www.example.com', // In addition, you can use the `pathRewrite` option provided by `next-http-proxy-middleware` pathRewrite: [{ patternStr: '^/api/new', replaceStr: '/v2' }, { patternStr: '^/api', replaceStr: '' }], + onProxyReq: (proxyReq, req, res) => {...}, + onProxyRes: (proxyRes, req, res) => {...}, })
This will allow more fine-grained request and response rewriting.
The text was updated successfully, but these errors were encountered:
Hi @AmauryM Please see #31 Thanks :)
Sorry, something went wrong.
#31 seems to solve onProxyReq, thanks.
How about onProxyRes?
If I do:
async function handler(req: NextApiRequest, res: NextApiResponse): Promise<void> { return httpProxyMiddleware(req, res, { target: TARGET_HOST, }) .then(() => { res.setHeader(...); }) }
then I get Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
feat: add onProxyInit option
onProxyInit
39065a1
* Added function to directly access `http-proxy` instance - Improved to be able to directly bind event to `http-proxy` instance. related: #50 #31
Hi @AmauryM From v1.2.0 version, you can access the http-proxy instance through an option. Please refer to the document. 😀 https://github.com/stegano/next-http-proxy-middleware#onproxyinit-option
http-proxy
Sounds good, thanks
stegano
No branches or pull requests
I think it would be useful to add
onProxyReq
andonProxyRes
options in the constructor function:This will allow more fine-grained request and response rewriting.
The text was updated successfully, but these errors were encountered: