midway-http-proxy-middleware
v1.0.0
Published
Midway component for http proxy, based on http-proxy-middleware
Downloads
14
Readme
Midway HTTP Proxy Component
Encapsulate the use of 'http proxy middleware' and maintain consistent configuration.
Applicable to @midwayjs/faas
、@midwayjs/web
、@midwayjs/koa
、 @midwayjs/express
multiple frameworks, support all HTTP proxy,for example GET、POST、PUT、DELETE request methods, support file upload and forwarding.
Usage
- Install dependencies
$ npm i midway-http-proxy-middleware --save
- Introduce components in
configuration
,
configuration.ts
import * as proxy from 'midway-http-proxy-middleware';
@Configuration({
imports: [
// ...other components
proxy
],
})
export class AutoConfiguration {}
Configure components
config.default.ts
export const httpProxyMiddleware = {
enable: true,
strategys: {
// example: If call 127.0.0.1:7001/api/ex, then proxy to http://127.0.0.1:8080, and rewrite /api as empty string.
// value: Completely equivalent http-proxy-middleware options
// ex: {
// target: 'http://127.0.0.1:8080',
// pathFilter: '/ex',
// pathRewrite: {
// '^/api': ''
// },
// changeOrigin: true,
// }
}
}