Skip to content

Proxy [Windows]

Planeson edited this page Jun 9, 2025 · 2 revisions

How to Install and Run a CORS Proxy on Windows

This guide will help you set up a simple CORS proxy server on Windows using Node.js.


1. Install Node.js

  1. Go to the Node.js download page.
  2. Download the LTS version for Windows.
  3. Run the installer and follow the prompts. Make sure to check the box to add Node.js to your PATH.

Verify the installation:

Open cmd and run:

node -v
npm -v

You should see version numbers for both.

2. Create the Proxy Server

  1. Create a new folder
  2. Navigate to the new folder in cmd.
  3. Initialize a new Node.js project:
npm init -y
  1. Install the required packages:
npm install express node-fetch@2 cors
  1. Create a file named index.js, copy the following and save:
const express = require('express');
const fetch = require('node-fetch');
const cors = require('cors');
const { exec } = require('child_process');

const app = express();
const PORT = 3000;

app.use(cors());

// Proxy route
app.get('/proxy', async (req, res) => {
    const targetUrl = req.query.url;
    if (!targetUrl) {
        return res.status(400).json({ error: 'Missing "url" query parameter.' });
    }

    try {
        const response = await fetch(targetUrl);
        const contentType = response.headers.get('content-type');
        res.setHeader('Content-Type', contentType);
        const body = await response.text();
        res.send(body);
    } catch (error) {
        res.status(500).json({ error: 'Failed to fetch target URL.', detail: error.message });
    }
});

// Time sync route (Windows)
app.get('/sync-time', (req, res) => {
    // First, ensure the Windows Time service is running
    exec('net start w32time', (startError, startStdout, startStderr) => {
        if (startError) {
            console.error(`Error starting w32time: ${startError.message}`);
            return res.status(500).json({ error: 'Failed to start w32time.', detail: startError.message });
        }
        // Now, try to resync the time
        exec('w32tm /resync', (error, stdout, stderr) => {
            if (error) {
                console.error(`Error syncing time: ${error.message}`);
                return res.status(500).json({ error: 'Failed to sync time.', detail: error.message });
            }
            if (stderr) {
                console.error(`stderr: ${stderr}`);
                return res.status(500).json({ error: 'Failed to sync time.', detail: stderr });
            }
            console.log(`Time synced successfully: ${stdout}`);
            res.json({ message: 'Time synced successfully.', output: stdout });
        });
    });
});

// Start the proxy server
app.listen(PORT, () => {
    console.log(`CORS proxy running at http://localhost:${PORT}`);
});

3: Ensure you have v2.3 or above installed.

4: Run the proxy

In the folder you installed the proxy in, run node index.js

First run the proxy, then start the html.

Clone this wiki locally