koa2-proxy-middleware
koa2-proxy-middleware copied to clipboard
Usage with middlewares
Is it possible to use this together with middlewares? I would like to check and modify some headers in the corresponding middleware.
@abimelex
- If you want to do something at request header or response header, you can use option. The usage is the same as http-proxy-middleware is. example:
options = {
targets: {
'/user': {
// this is option of http-proxy-middleware
target: 'http://localhost:3001', // target host
changeOrigin: true, // needed for virtual hosted sites
onProxyRes: (proxyRes, req, res) => {
proxyRes.headers['x-added'] = 'foobar' // add new header to response
}
}
}
}
options look at http-proxy-middleware options
- Is it possible use this middleware with other? yes, it is. If you want to check something,just write a middleware and put it in front of koa2-proxy-middleware...