Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 28, 2023
1 parent 4e9b2c5 commit f718485
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions proxy/server.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const express = require('express');
const cors = require('cors');
const axios = require('axios');
const rateLimit = require('express-rate-limit');
const express = require("express");
const cors = require("cors");
const axios = require("axios");
const rateLimit = require("express-rate-limit");

const app = express();
const port = 3000;

// CORS middleware settings
const corsOptions = {
origin: (origin, callback) => {
if (origin === 'https://taxonium.org') {
if (origin === "https://taxonium.org") {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
callback(new Error("Not allowed by CORS"));
}
},
methods: ['GET']
methods: ["GET"],
};

// Apply CORS
Expand All @@ -24,14 +24,14 @@ app.use(cors(corsOptions));
// Rate limiting middleware
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100 // limit each IP to 100 requests per windowMs
max: 100, // limit each IP to 100 requests per windowMs
});

// Apply the rate limiter to all requests
app.use(limiter);

// Proxy endpoint
app.get('/proxy', async (req, res) => {
app.get("/proxy", async (req, res) => {
try {
const response = await axios.get(req.query.url);
res.send(response.data);
Expand Down

0 comments on commit f718485

Please sign in to comment.