
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
http-proxy-404
Advanced tools
http-proxy-404 just proxy serve,proxy 404 interface to target servers
just proxy serve,proxy 404 interface to target servers
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
$ npm install http-proxy-404 --save-dev
or
$ yarn add http-proxy-404 -D
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"
},
Name | Required | Type | Default | Description |
---|---|---|---|---|
port | false | {Number} | 8081 | Proxy service port,If the port is occupied will port++ and until the port is available |
log | false | {Boolean} | true | Whether to print the log |
apiReg | true | {RegExp} | null | Interface matching rule |
changeOrigin | false | {Boolean} | true | changes the origin of the host header to the target URL |
ws | false | {Boolean} | false | if you want to proxy websockets |
404func | false | {Function} | null | Custom function used to determine 404;Return true means you want to proxy next;Return false instead |
200func | false | {Function} | null | Custom 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 |
secure | false | {Boolean} | false | if you want to verify the SSL Certs |
2019-11-25:
200func
FAQs
http-proxy-404 just proxy serve,proxy 404 interface to target servers
The npm package http-proxy-404 receives a total of 2 weekly downloads. As such, http-proxy-404 popularity was classified as not popular.
We found that http-proxy-404 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.