http-proxy-with-cors

1.2.5 • Public • Published

HTTP proxy with cors

npm

Proxy HTTP requests with cors enabled.

At my company, sometimes we wanna run our local frontend against production, it's easier and faster, the problem is CORS

So I created the following npm package that act as a proxy to multiple upstream servers built on top of fastifyjs so you wont feel it

Usage

It will create a proxy server on each local port that will proxy all requests to the upstream server.

CLI arguments

npx http-proxy-with-cors <local-port-1> <upstream-1> ... <local-port-n> <upstream-n>

From file

npx http-proxy-with-cors --file <path-to-json-file>

Example config file:

[
  {
    "port": 3000,
    "upstream": "https://us1.api.server.com"
  },
  {
    "port": 3001,
    "upstream": "https://us2.api.server.com"
  }
]

Options

Config

you can pass the server from a config file using (-f or --file) or pass them as port and upstream arguments.

Logging

To disable logging, set the LOG_DISABLED environment variable to true.

Readme

Keywords

Package Sidebar

Install

npm i http-proxy-with-cors

Weekly Downloads

3

Version

1.2.5

License

MIT

Unpacked Size

10.1 kB

Total Files

8

Last publish

Collaborators

  • rluvaton