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
It will create a proxy server on each local port that will proxy all requests to the upstream server.
npx http-proxy-with-cors <local-port-1> <upstream-1> ... <local-port-n> <upstream-n>
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"
}
]
you can pass the server from a config file using (-f
or --file
) or pass them as port
and upstream
arguments.
To disable logging, set the LOG_DISABLED
environment variable to true
.