mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
🛠️ Trying to fix CORS error, use it to global routes + clean redis url
This commit is contained in:
@@ -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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user