Skip to content

zhanxin-xu/node-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js HTTP/HTTPS Proxy Server

A TypeScript-based HTTP/HTTPS proxy server that forwards requests to a specified URL and logs both requests and responses.

Features

  • Forwards HTTP/HTTPS requests to a configurable target URL
  • Logs detailed information about requests and responses
  • Configurable via environment variables
  • Written in TypeScript for better type safety and developer experience

Installation

  1. Clone this repository
  2. Install dependencies:
npm install

Configuration

Create a .env file in the root directory (you can copy from .env.example):

PORT=3000
TARGET_URL=https://api.example.com
  • PORT: The port on which the proxy server will listen (default: 3000)
  • TARGET_URL: The target URL to which requests will be forwarded (required)

Usage

Development

npm run dev

Production

Build the project:

npm run build

Start the server:

npm start

How It Works

  1. The proxy server receives an HTTP/HTTPS request
  2. It forwards the request to the configured target URL
  3. It logs details about the request (method, path, headers, body)
  4. It receives the response from the target server
  5. It logs details about the response (status, headers, data)
  6. It forwards the response back to the client

License

ISC

About

Node.js HTTP/HTTPS Proxy Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published