-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
23 lines (22 loc) · 1.07 KB
/
server.js
File metadata and controls
23 lines (22 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const express = require('express');
const axios = require('axios');
const cors = require('cors');
const app = express();
app.use(cors());
app.get('/proxy', async (req, res) => {
try {
const response = await axios.get(req.query.url, {
headers: { 'User-Agent': 'Mediapartners-Google' }, // You can edit this, I recommend keeping it
// to Mediapartners-Google because that's allowed on a bunch of Google services.
responseType: 'arraybuffer',
validateStatus: () => true // Always return the body, even on error
});
res.set('Content-Type', response.headers['content-type']);
res.send(response.data);
} catch (error) {
res.status(200).send(`Proxy Error: ${error.message}`);
}
});
app.listen(3000, () => console.log('IMPORTANT: Do NOT close this tab if you want the server running!')),
app.listen(3000, () => console.log('Proxy active at http://localhost:3000')),
app.listen(3000, () => console.log('If you ran the file from VBS, which you should, a HTML tab will be opened shortly.'));