Skip to content

Trie-Network/cors-proxy-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Proxy Server

HTTP proxy server that forwards requests to http://localhost:20001.

We use this proxy because the Rubix node does not handle CORS. The proxy adds the required CORS headers so that browser-based requests work without errors.

Features

  • HTTP/HTTPS request forwarding
  • CORS support
  • Request logging
  • Health check endpoint
  • Error handling
  • Configurable target URL

Installation

npm install

Usage

Development:

npm run dev

Production:

npm start

Custom port:

PORT=8080 npm start

Configuration

Default target: http://localhost:20001. Change TARGET_URL in server.js to modify.

Endpoints

  • GET /health: Returns server status
  • All other routes: Forwarded to target URL with method, headers, body, and query string preserved

Example

# Health check
curl http://localhost:3000/health

# Forward request
curl http://localhost:3000/api/data
# Goes to http://localhost:20001/api/data

Logging

Requests and proxy operations logged to console.

Error Handling

  • Proxy errors return JSON responses
  • Target unavailability handled with error messages

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published