A lightweight Dockerized proxy to forward local API requests to an external API server.
This proxy allows local applications to make requests to an external API as if it were a local service. It forwards all requests, handles headers, and bypasses SSL verification for internal certificates.
- Docker
- Node.js (only for local debugging)
- Build the Docker image:
docker build --no-cache --tag simple-api-proxy . - Run the container on port 8080, setting
BASE_HOSTenv variable.:The proxy will listen ondocker run --rm -p 8080:8080 -e BASE_HOST=jsonplaceholder.typicode.com simple-api-proxy
http://localhost:8080
Once the proxy is running, make requests to an externel API via the proxy:
curl http://localhost:8080/todos/1or in a client application:
fetch('http://localhost:8080/todos/1')
.then(response => response.json())
.then(data => console.log(data));