Skip to content

A simple Node.js-based CORS Proxy Server to bypass CORS restrictions and fetch data from external URLs.

License

Notifications You must be signed in to change notification settings

AsifKamboh-COM/cors-proxy-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version
Maintained YES
Ask Me Anything !

📌 CORS Proxy Server

CORS Proxy Server

CORS Proxy Server is a simple and efficient proxy server built with Node.js and Express.js to fetch headers and HTML content from any URL, bypassing CORS restrictions. It comes with a user-friendly front-end interface. Live Demo

Features

  • Handles CORS (Cross-Origin Resource Sharing) requests
  • Fetch headers and HTML content from any URL
  • Simple UI built with Tailwind CSS
  • Deployable on Vercel, Render, and other platforms
  • Improved error handling and redirection support

📂 Repository Structure

/cors-proxy-server
│-- public/
│   └── index.html  # Frontend UI
│-- server.js       # Node.js backend server
│-- package.json    # Dependencies and scripts
│-- vercel.json     # Vercel deployment configuration
│-- README.md       # Documentation
│-- LICENSE         # License

Install Installation

🔹 Prerequisites

  • Node.js (v16 or higher)
  • Yarn or NPM

🔹 Clone the Repository

git clone https://github.com/AsifKamboh-COM/cors-proxy-server.git
cd cors-proxy-server

🔹 Install Dependencies

Using Yarn:

yarn install

Using NPM:

npm install

🔹 Start the Server

yarn start

or

npm start

Easy to Use Usage

Once the server is running, you can use the proxy by making a request to:

http://localhost:3000/proxy?url=<TARGET_URL>

Example:

http://localhost:3000/proxy?url=https://example.com

This will return:

  • Response status (e.g., HTTP/2 200 OK)
  • Response headers (all headers from the target URL)
  • Full HTML content of the requested page

Deployed Deployment

🔹 Deploy on Vercel

To deploy this CORS Proxy Server on Vercel, follow these steps:

  1. Fork or clone the repository.

  2. Install Vercel CLI if not already installed:

    npm install -g vercel
  3. Login to Vercel:

    vercel login
  4. Navigate to the project directory and deploy:

    vercel

    Follow the instructions to complete the deployment.

🔹 Deploy on Render

  1. Push your code to GitHub
  2. Create a new Web Service on Render
  3. Connect your GitHub repository
  4. Set the build command:
    yarn install
  5. Set the start command:
    yarn start
  6. Deploy and get your Render URL!

ENV Optional Environment Variables (Optional)

You can configure the following environment variables:

  • PORT (default: 3000)

Error Handling Error Handling

If you get the error:

{
  "status": "Failed to fetch URL",
  "error": "Invalid URL"
}

Fixed Possible Fixes:

  • Make sure the target URL is publicly accessible.
  • If the request is blocked due to CORS, try using different headers.
  • Some sites have anti-bot protections, which may cause failures.

License: MIT License

This project is licensed under the MIT License.

Built & Maintained By Built & Maintained By

Asif KambohDeveloper & Open-Source Contributor