Installations
npm install koa-proxies
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.8.1
NPM Version
10.1.0
Score
49.7
Supply Chain
95.9
Quality
73.2
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
Download Statistics
Total Downloads
4,621,307
Last Day
1,270
Last Week
7,586
Last Month
59,190
Last Year
952,027
GitHub Statistics
161 Stars
91 Commits
45 Forks
3 Watching
3 Branches
14 Contributors
Package Meta Information
Latest Version
0.12.4
Package Id
koa-proxies@0.12.4
Unpacked Size
13.39 kB
Size
5.39 kB
File Count
8
NPM Version
10.1.0
Node Version
20.8.1
Publised On
04 Nov 2023
Total Downloads
Cumulative downloads
Total Downloads
4,621,307
Last day
-39.3%
1,270
Compared to previous day
Last week
-45.9%
7,586
Compared to previous week
Last month
-15%
59,190
Compared to previous month
Last year
-23.4%
952,027
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Peer Dependencies
1
Koa Proxies
Koa@2.x/next middlware for http proxy
Powered by http-proxy
.
Installation
1$ npm install koa-proxies --save
Options
http-proxy events
1options.events = { 2 error (err, req, res) { }, 3 proxyReq (proxyReq, req, res) { }, 4 proxyRes (proxyRes, req, res) { } 5}
log option
1// enable log
2options.logs = true; // or false
3
4// custom log function
5options.logs = (ctx, target) {
6 console.log('%s - %s %s proxy to -> %s', new Date().toISOString(), ctx.req.method, ctx.req.oldPath, new URL(ctx.req.url, target))
7}
Usage
1// dependencies 2const Koa = require('koa') 3const proxy = require('koa-proxies') 4const httpsProxyAgent = require('https-proxy-agent') 5 6const app = new Koa() 7 8// middleware 9app.use(proxy('/octocat', { 10 target: 'https://api.github.com/users/', 11 changeOrigin: true, 12 agent: new httpsProxyAgent('http://1.2.3.4:88'), // if you need or just delete this line 13 rewrite: path => path.replace(/^\/octocat(\/|\/\w+)?$/, '/vagusx'), 14 logs: true 15}))
The 2nd parameter options
can be a function. It will be called with the path matching result (see path-match for details) and Koa ctx
object. You can leverage this feature to dynamically set proxy. Here is an example:
1// dependencies 2const Koa = require('koa') 3const proxy = require('koa-proxies') 4 5const app = new Koa() 6 7// middleware 8app.use(proxy('/octocat/:name', (params, ctx) => { 9 return { 10 target: 'https://api.github.com/', 11 changeOrigin: true, 12 rewrite: () => `/users/${params.name}`, 13 logs: true 14 }}) 15)
Moreover, if the options
function return false
, then the proxy will be bypassed. This allows the middleware to bail out even if path matching succeeds, which could be helpful if you need complex logic to determine whether to proxy or not.
Attention
Please make sure that koa-proxies
is in front of koa-bodyparser
to avoid this issue 55
1const Koa = require('koa') 2const app = new Koa() 3const proxy = require('koa-proxies') 4const bodyParser = require('koa-bodyparser') 5 6app.use(proxy('/user', { 7 target: 'http://example.com', 8 changeOrigin: true 9})) 10 11app.use(bodyParser())
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 8/26 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/vagusX/koa-proxies/node.js.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/vagusX/koa-proxies/node.js.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/node.js.yml:29
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 2 npmCommand dependencies pinned
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/node.js.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 20 are checked with a SAST tool
Score
4.2
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to koa-proxies
@types/koa-proxies
Stub TypeScript definitions entry for koa-proxies, which provides its own types definitions
koa-better-proxies
Http Proxy Middleware for Koa@2.x/next, change by koa-proxies
koa-proxies-better
Http Proxy Middleware for Koa@2.x/next
koa-proxies-filter
Http Proxy Middleware for Koa@2.x/next