# dev-backend-proxy

> Proxy remote backend for local development with CORS and Cookies

Latest version **1.0.9** (published 2023-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install dev-backend-proxy
pnpm add dev-backend-proxy
yarn add dev-backend-proxy
bun add dev-backend-proxy
```

Provides the command `dev-backend-proxy`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2023-01-17 |
| First published | 2023-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Andrey Lugovskoy |
| Maintainers | bearlogin |
| Keywords | developer, tools, proxy, backend |

## Links

- npm: https://www.npmjs.com/package/dev-backend-proxy
- Repository: https://github.com/BEARlogin/backend-docker-proxy
- Homepage: https://github.com/BEARlogin/backend-docker-proxy#readme
- Issues: https://github.com/BEARlogin/backend-docker-proxy/issues
- npm.io page: https://npm.io/package/dev-backend-proxy

## Dependencies (9)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [yargs](https://npm.io/package/yargs.md) ^17.6.2
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.3
- [express](https://npm.io/package/express.md) ^4.18.2
- [body-parser](https://npm.io/package/body-parser.md) ^1.20.1
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.6
- [express-http-proxy](https://npm.io/package/express-http-proxy.md) ^1.6.3
- [express-static-proxy](https://npm.io/package/express-static-proxy.md) ^1.0.0
- [http-proxy-middleware](https://npm.io/package/http-proxy-middleware.md) ^2.0.6

## Recent versions

- 1.0.9 (latest) — 2023-01-17
- 1.0.8 — 2023-01-15
- 1.0.7 — 2023-01-13
- 1.0.5 — 2023-01-13
- 1.0.3 — 2023-01-10
- 1.0.2 — 2023-01-03
- 1.0.1 — 2023-01-03

## README

<!-- ABOUT THE PROJECT -->
## About The Project

Frontend developers often face with case, where they should use remote API development server.
And if it uses https protocol and some sort cookie-based authorization and/or CORS, you should run https dev environment,
that not so often easy to run.

Special case - development under Windows with Docker... It's some sort of BDSM :)
And it's a right decision to use remote API in that case.

Having faced these problems more than once, I've made an image and compose for frontend developers that make it easy to proxy a remote backend locally.


### Prerequisites

Things you need to use the software and how to install them.
* docker
* docker-compose (or docker with compose plugin)
* OR NodeJS 16+

### Installation and usage

## Run CLI with npx

```shell
npx dev-backend-proxy -t https://jsonplaceholder.typicode.com -r https://jsonplaceholder.typicode.com -p 3001
```

## Run with docker or NodeJS

1. Clone repo


2. Copy .env.example to .env
    ```sh
    cp .env.example .env
   ```
3. Build and run docker-compose or use NodeJS
   ```sh
   docker-compose up -d --build
   ```
   Or with NodeJS   
   ```sh
   npm install & npm run start
   ```
4. Open [http://localhost:3001/todos/](http://localhost:3001/todos/) and see response from [https://jsonplaceholder.typicode.com/todos/](https://jsonplaceholder.typicode.com/todos/)


5. Replace environments for your purposes and repeat step 2

| **Env**         | **Description**                                    |
|-----------------|----------------------------------------------------|
| PROXY_TO        | Target                                             |
| HOST_PORT       | Where service should listen                        |
| REPLACED_ORIGIN | What origin we should use to replace Origin header |

5. PROFIT!


<!-- LICENSE -->
## License

Distributed under the MIT License.

---
_Source: https://npm.io/package/dev-backend-proxy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
