-
Notifications
You must be signed in to change notification settings - Fork 2
Proxy [Windows]
Planeson edited this page Jun 9, 2025
·
2 revisions
This guide will help you set up a simple CORS proxy server on Windows using Node.js.
- Go to the Node.js download page.
- Download the LTS version for Windows.
- 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 -vYou should see version numbers for both.
- Create a new folder
- Navigate to the new folder in cmd.
- Initialize a new Node.js project:
npm init -y- Install the required packages:
npm install express node-fetch@2 cors- 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}`);
});In the folder you installed the proxy in, run node index.js
First run the proxy, then start the html.