Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
koa2-proxy-middleware
Advanced tools
Readme
A koa2 middleware by means of http-proxy-middleware.
$ npm install --save-dev koa2-proxy-middleware
This is a very simple usage. If you are familiar with the use of http-proxy-middleware and path-to-regexp.
const Koa = require('koa');
const proxy = require('koa2-proxy-middleware');
const bodyparser = require('koa-bodyparser');
const app = new Koa();
const options = {
targets: {
'/user': {
// this is option of http-proxy-middleware
target: 'http://localhost:3000', // target host
changeOrigin: true, // needed for virtual hosted sites
},
'/user/:id': {
target: 'http://localhost:3001',
changeOrigin: true,
},
// (.*) means anything
'/api/(.*)': {
target: 'http://10.94.123.123:1234',
changeOrigin: true,
pathRewrite: {
'/passager/xx': '/mPassenger/ee', // rewrite path
}
},
}
}
app.use(proxy(options));
app.use(bodyparser({
enableTypes:['json', 'form', 'text']
}));
{
targets: {
[key]: [option],
},
}
The key route that you need to proxy.And through path-to-regexp into regexp. This is mean:
const regexp = pathToRegexp('route-key');
regexp.test(ctx.req.path);
The option corresponding to key and like http-proxy-middleware.
Bodyparser need to after proxy-middleware when request method is POST. Otherwise there will be a delay. I think this is a bug of bodyparser.
FAQs
a koa2 proxy middleware by means of http-proxy-middleware
The npm package koa2-proxy-middleware receives a total of 714 weekly downloads. As such, koa2-proxy-middleware popularity was classified as not popular.
We found that koa2-proxy-middleware 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.