Skip to content
This repository has been archived by the owner. It is now read-only.
[DEPRECATED] Simplest proxy server for microservices
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Initial commit. Nov 27, 2017
lib Fix replacement of special characters (#35) Dec 3, 2018
test Don’t follow redirects (#36) Dec 3, 2018
.gitignore
.travis.yml Add .travis.yml Dec 3, 2017
index.js Don’t follow redirects (#36) Dec 3, 2018
license.md Initial commit. Nov 27, 2017
package.json Release 1.1.0 Jan 11, 2018
readme.md Update readme.md Mar 8, 2019
yarn.lock Basic ws support (#4) Jan 11, 2018

readme.md

DEPRECATED. This project is unmaintained in favor of now-cli development mode (now dev). micro remains fully supported and under active development.

micro-proxy

Build Status

Usage

Firstly, install the package:

npm i -g micro-proxy

Then add following rules to a filename called rules.json:

{
  "rules": [
    {"pathname": "/blog", "method":["GET", "POST", "OPTIONS"], "dest": "http://localhost:5000"},
    {"pathname": "/**", "dest": "http://localhost:4000"}
  ]
}

Visit path alias documentation to learn more about rules.

Run the proxy server with:

micro-proxy -r rules.json -p 9000

Now you can access the proxy via: http://localhost:9000

Programmatic Usage

You can run the proxy programmatically inside your codebase. For that, add micro-proxy to your project with:

npm install micro-proxy

Then create the proxy server like this:

const createProxy = require('micro-proxy')
const proxy = createProxy([
  {"pathname": "/blog", "method":["GET", "POST", "OPTIONS"], "dest": "http://localhost:5000"},
  {"pathname": "/**", "dest": "http://localhost:4000"}
])

proxy.listen(9000, (err) => {
  if (err) {
    throw err
  }
  console.log(`> Ready on http://localhost:9000`)
})

Production Usage

You can use micro-proxy as a production deployment.

But if you are using ZEIT now, you can simply use path alias rules instead.
(It's a FREE service available for all ZEIT now deployments.)

You can’t perform that action at this time.