🛠️ Trying to fix CORS error, use it to global routes + clean redis url

This commit is contained in:
pheralb
2025-08-05 12:30:59 +01:00
parent f555ea67da
commit 000c079c29
+3 -2
View File
@@ -40,9 +40,10 @@ class RedisRateLimiter {
UPSTASH_REDIS_URL: string; UPSTASH_REDIS_URL: string;
UPSTASH_REDIS_TOKEN: string; UPSTASH_REDIS_TOKEN: string;
}>(c); }>(c);
const cleanRedisUrl = UPSTASH_REDIS_URL.replace(/^['"]|['"]$/g, '').trim();
const redisClient = new Redis({ const redisClient = new Redis({
token: UPSTASH_REDIS_TOKEN, token: UPSTASH_REDIS_TOKEN,
url: UPSTASH_REDIS_URL url: cleanRedisUrl
}); });
const ratelimit = new Ratelimit({ const ratelimit = new Ratelimit({
redis: redisClient, redis: redisClient,
@@ -63,7 +64,7 @@ app.use(async (c, next) => {
await next(); await next();
}); });
app.use('/api/*', cors()); app.use(cors());
// 🌱 GET: "/" - Returns all the SVGs data: // 🌱 GET: "/" - Returns all the SVGs data:
app.get('/', async (c) => { app.get('/', async (c) => {