Skip to content

Usage with middlewares #4

New issue

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

Open
karladler opened this issue Nov 27, 2018 · 1 comment
Open

Usage with middlewares #4

karladler opened this issue Nov 27, 2018 · 1 comment

Comments

@karladler
Copy link

Is it possible to use this together with middlewares?
I would like to check and modify some headers in the corresponding middleware.

@sunyongjian
Copy link
Owner

sunyongjian commented Nov 28, 2018

@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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants