
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
@fuadop/koa-proxy
Advanced tools
Proxy middleware for koa
$ npm install koa-proxy -S
When you request http://localhost:3000/index.js, it will fetch http://alicdn.com/index.js and return.
var koa = require('koa');
var proxy = require('koa-proxy');
var app = koa();
app.use(proxy({
host: 'http://alicdn.com'
}));
app.listen(3000);
You can proxy a specified url.
app.get('index.js', proxy({
url: 'http://alicdn.com/index.js'
}));
You can specify a key/value object that can map your request's path to the other.
app.get('index.js', proxy({
host: 'http://alicdn.com',
map: {
'index.js': 'index-1.js'
}
}));
You can specify a function that can map your request's path to the desired destination.
app.get('index.js', proxy({
host: 'http://alicdn.com',
map: function(path) { return 'public/' + path; }
}));
You can specify match criteria to restrict proxy calls to a given path.
app.use(proxy({
host: 'http://alicdn.com', // proxy alicdn.com...
match: /^\/static\// // ...just the /static folder
}));
Or you can use match to exclude a specific path.
app.use(proxy({
host: 'http://alicdn.com', // proxy alicdn.com...
match: /^(?!\/dontproxy\.html)/ // ...everything except /dontproxy.html
}));
You can configure proxy to remember cookies for future use by setting jar = true
. This means cookies set by server will be stored and resent in subsequent requests. For me info see the documentation for request.
app.use(proxy({
jar: true,
}));
Proxy won't send 'foo' and 'bar' headers to real server, or recieve 'jar-jar' from real server.
app.use(proxy({
suppressRequestHeaders: ['foo','bar'], // case-insensitive
suppressResponseHeaders: ['jar-jar'] // case-insensitive
}));
You can also add new headers to your response or override existing ones
app.use(proxy({
overrideResponseHeaders: {
"cow": "moo",
"duck": "quack"
},
}));
Copyright (c) 2014 popomore. Licensed under the MIT license.
FAQs
Proxy middleware for koa
The npm package @fuadop/koa-proxy receives a total of 1 weekly downloads. As such, @fuadop/koa-proxy popularity was classified as not popular.
We found that @fuadop/koa-proxy 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.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.