Any roblos url

This commit is contained in:
Christopher Cookman 2024-08-05 15:33:30 -06:00
parent 2be833794a
commit 450de36336
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -1,6 +1,10 @@
const express = require('express');
const axios = require('axios');
const allowedDomains = [
"roblox.com"
]
const app = express();
const rateLimit = require("express-rate-limit");
@ -11,18 +15,27 @@ app.use(rateLimit({
keyGenerator: (req) => req.headers["x-forwarded-for"] || req.connection.remoteAddress,
}));
app.get("/*", (req, res) => {
// get the full path with arguments and proxy it to https://api.roblox.com/
const path = req.path;
const url = `https://apis.roblox.com${path}`;
console.log(`Proxying request to ${url}`);
// get the response from the url and send it back to the client
axios.get(url).then((response) => {
res.send(response.data);
app.get("/:domain/*", (req, res) => {
// get the domain and the rest of the path+args
const domain = req.params.domain;
const path = req.params[0];
const args = req.query;
// Check that domain is equal or subdomain of allowedDomains
if (!allowedDomains.some((allowedDomain) => domain.endsWith(allowedDomain))) {
res.status(403).send("Domain not allowed");
return;
}
// Make the request
axios.get(`https://${domain}/${path}`, {
params: args
}).then((response) => {
// Send the response back
res.status(response.status).send(response.data);
}).catch((error) => {
res.status(500).send(error);
})
// Send the error back
res.status(error.response.status).send(error.response.data);
});
});
const port = process.env.SERVER_PORT || 3000;