Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-proxy-404

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-proxy-404

http-proxy-404 just proxy serve,proxy 404 interface to target servers

  • 0.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

http-proxy-404

just proxy serve,proxy 404 interface to target servers

Introduction

http-proxy-404mock 是一个基于http-proxy-middleware 开发的node代理服务器

Http-proxy-404 is a node proxy server based on http-proxy-middleware

你可以用它做什么呢?

What can you do with it?

你可以配置一堆不同环境的接口服务地址

You can configure a bunch of interface service addresses for different environments.

它会自动嗅探接口在当前配置的服务器地址中 请求的response的状态是否为404,如果请求的状态是404,它会往下一个地址中继续请求,直至成功

It will automatically sniff the interface to request the response status in the currently configured server address is 404,If the status of the request is 404, it will continue the request to the next address until it succeeds

Install

$ npm install http-proxy-404 --save-dev

or

$ yarn add http-proxy-404 -D

Usage

step1: create serve.js

const Proxy404 = require('http-proxy-404')

new Proxy404({
  port: 8081,
  apiReg: '/api*',
  targetList: [
    'target host1',
    'target host2',
    'target host3'
  ],
  '404func': function(res) {
    if(!res.response) {
      return true
    }
  }
})

step2: Configuring webpack

proxy: {
    '/': {
      target: "http://x.x.x.x:port", // Please fill in the proxy service address output by http-proxy-404
      ws: false,
      changeOrigin: true,
    }
  }

step3: run serve.js

nodemon serve.js

or in your package.json

"scripts": {
    "dev": "webpack-dev-server xxx & nodemon serve.js"
  },

options

NameRequiredTypeDefaultDescription
portfalse{Number}8081Proxy service port,If the port is occupied will port++ and until the port is available
logfalse{Boolean}trueWhether to print the log
apiRegtrue{RegExp}nullInterface matching rule
changeOriginfalse{Boolean}truechanges the origin of the host header to the target URL
wsfalse{Boolean}falseif you want to proxy websockets
404funcfalse{Function}nullCustom function used to determine 404;Return true means you want to proxy next;Return false instead
200funcfalse{Function}nullCustom function used to determine 200;Return true means you want to proxy next;Return false instead;If you return a string, it will be defaulted to the address of the mandatory proxy
securefalse{Boolean}falseif you want to verify the SSL Certs

update log

2019-11-25:

  • 新增 参数配置 200func
  • 新增自动检测端口占用功能,并自动分配可用端口

Keywords

FAQs

Package last updated on 25 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc