mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
17 lines
483 B
JavaScript
17 lines
483 B
JavaScript
const { createProxyServer } = require('../../');
|
|
const http = require('http');
|
|
|
|
const proxy = createProxyServer({});
|
|
const agent = new http.Agent({ keepAlive: true})
|
|
|
|
const server = http.createServer(function(req, res) {
|
|
// You can define here your custom logic to handle the request
|
|
// and then proxy the request.
|
|
proxy.web(req, res, {
|
|
target: 'http://localhost:9000',
|
|
agent: agent
|
|
});
|
|
});
|
|
|
|
console.log('listening on port 8000');
|
|
server.listen(8000); |