const express = require('express'); const axios = require('axios'); const allowedDomains = [ "roblox.com" ] const app = express(); const rateLimit = require("express-rate-limit"); app.enable("trust proxy"); app.use(rateLimit({ windowMs: 20000, max: 10, keyGenerator: (req) => req.headers["x-forwarded-for"] || req.connection.remoteAddress, })); 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) => { // Send the error back res.status(error.response.status).send(error.response.data); }); }); const port = process.env.SERVER_PORT || 3000; app.listen(port, () => { console.log(`Server is running on port ${port}`); });