3.8.1 • Published 3 years ago

@huangapple/midway-http-proxy v3.8.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

HTTP 代理组件

HTTP 代理组件

适用于 @midwayjs/faas@midwayjs/web@midwayjs/koa@midwayjs/express 多种框架的 HTTP 代理组件,支持GET、POST等多种请求方法。

Usage

  1. 安装依赖
$ npm i @midwayjs/http-proxy --save
  1. 在 configuration 中引入组件,
import * as proxy from '@midwayjs/http-proxy';
@Configuration({
  imports: [
    // ...other components
    proxy
  ],
})
export class AutoConfiguration {}

配置

export const httpProxy = {
  host: 'http://127.0.0.1',
  match: /\/assets\/(.*)/,
  target: 'http://127.0.0.1/$1',

  //额外的axios请求config, 会照搬过去
  extReqOptions:{
    //用来设置不校验https的ssl
    httpsAgent: new https.Agent({ rejectUnauthorized: false })
  }
}