Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const express = require('express');
const cors = require('cors');
const { createProxyMiddleware } = require('http-proxy-middleware');

const app = express();

// 1. Allow All Origins (Public Proxy Mode)
app.use(cors({
origin: '*',
methods: ['GET', 'POST', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'X-MBX-APIKEY'],
credentials: false
}));

// 2. Health Check
app.get('/', (req, res) => {
res.send('Quantum Proxy is Running on Glitch!');
});

// 3. Proxy Logic
const proxyOptions = {
target: 'https://api.binance.com',
changeOrigin: true,
pathRewrite: {
'^/api/v3': '/api/v3'
},
onProxyRes: (proxyRes) => {
// Strip restrictive headers from Binance so browser accepts response
delete proxyRes.headers['access-control-allow-origin'];
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
}
};

app.use('/api', createProxyMiddleware(proxyOptions));

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});