mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-10 06:08:34 +01:00
add more liks
This commit is contained in:
parent
f83186514e
commit
5233aba0e0
1 changed files with 25 additions and 21 deletions
38
p/server.js
38
p/server.js
|
@ -4,18 +4,21 @@ const { URL } = require("url");
|
||||||
|
|
||||||
// Array of hostnames that will be proxied
|
// Array of hostnames that will be proxied
|
||||||
const URL_WHITELIST = [
|
const URL_WHITELIST = [
|
||||||
'i.ytimg.com',
|
"i.ytimg.com",
|
||||||
'yt3.googleusercontent.com',
|
"yt3.googleusercontent.com",
|
||||||
'cdn.glitch.global',
|
"cdn.glitch.global",
|
||||||
'cdn.statically.io',
|
"cdn.statically.io",
|
||||||
'site-assets.fontawesome.com',
|
"site-assets.fontawesome.com",
|
||||||
'fonts.gstatic.com',
|
"fonts.gstatic.com",
|
||||||
'yt3.ggpht.com',
|
"yt3.ggpht.com",
|
||||||
'tube.kuylar.dev',
|
"tube.kuylar.dev",
|
||||||
'lh3.googleusercontent.com',
|
"lh3.googleusercontent.com",
|
||||||
'is4-ssl.mzstatic.com',
|
"is4-ssl.mzstatic.com",
|
||||||
'twemoji.maxcdn.com',
|
"is2-ssl.mzstatic.com",
|
||||||
'unpkg.com',
|
"is1-ssl.mzstatic.com",
|
||||||
|
"is3-ssl.mzstatic.com",
|
||||||
|
"twemoji.maxcdn.com",
|
||||||
|
"unpkg.com",
|
||||||
];
|
];
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
@ -24,7 +27,7 @@ app.use(express.json()); // for parsing application/json
|
||||||
app.use(express.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
app.use(express.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
||||||
|
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
console.log(`=> ${req.method} ${req.originalUrl.slice(1)}`)
|
console.log(`=> ${req.method} ${req.originalUrl.slice(1)}`);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -44,8 +47,8 @@ const proxy = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
url = new URL("https://" + req.originalUrl.slice(10));
|
url = new URL("https://" + req.originalUrl.slice(10));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('==> Cannot parse URL: ' + e);
|
console.log("==> Cannot parse URL: " + e);
|
||||||
return res.status(400).send('Malformed URL');
|
return res.status(400).send("Malformed URL");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!URL_WHITELIST.includes(url.host)) {
|
if (!URL_WHITELIST.includes(url.host)) {
|
||||||
|
@ -61,9 +64,10 @@ const proxy = async (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
f.body.pipe(res);
|
f.body.pipe(res);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`==> Error: ${e}`);
|
console.log(`==> Error: ${e}`);
|
||||||
res.status(500).send('Internal server error');
|
res.status(500).send("Internal server error");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,4 +81,4 @@ app.get("/", (req, res) =>
|
||||||
|
|
||||||
app.all("/*", listener);
|
app.all("/*", listener);
|
||||||
|
|
||||||
app.listen(3000, () => console.log('Listening on 0.0.0.0:3000'));
|
app.listen(3000, () => console.log("Listening on 0.0.0.0:3000"));
|
||||||
|
|
Loading…
Reference in a new issue