31 lines
852 B
JavaScript
31 lines
852 B
JavaScript
const express = require('express');
|
|
const axios = require('axios');
|
|
|
|
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("/*", (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);
|
|
}).catch((error) => {
|
|
res.status(500).send(error);
|
|
})
|
|
|
|
});
|
|
|
|
const port = process.env.SERVER_PORT || 3000;
|
|
app.listen(port, () => {
|
|
console.log(`Server is running on port ${port}`);
|
|
}); |