@huangapple/midway-http-proxy
TypeScript icon, indicating that this package has built-in type declarations

3.8.1 • Public • Published

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 })
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @huangapple/midway-http-proxy

Weekly Downloads

0

Version

3.8.1

License

MIT

Unpacked Size

20.6 kB

Total Files

14

Last publish

Collaborators

  • huangapple