Skip to content

Commit 000c079

Browse files
committed
🛠️ Trying to fix CORS error, use it to global routes + clean redis url
1 parent f555ea6 commit 000c079

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

api-routes/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ class RedisRateLimiter {
4040
UPSTASH_REDIS_URL: string;
4141
UPSTASH_REDIS_TOKEN: string;
4242
}>(c);
43+
const cleanRedisUrl = UPSTASH_REDIS_URL.replace(/^['"]|['"]$/g, '').trim();
4344
const redisClient = new Redis({
4445
token: UPSTASH_REDIS_TOKEN,
45-
url: UPSTASH_REDIS_URL
46+
url: cleanRedisUrl
4647
});
4748
const ratelimit = new Ratelimit({
4849
redis: redisClient,
@@ -63,7 +64,7 @@ app.use(async (c, next) => {
6364
await next();
6465
});
6566

66-
app.use('/api/*', cors());
67+
app.use(cors());
6768

6869
// 🌱 GET: "/" - Returns all the SVGs data:
6970
app.get('/', async (c) => {

0 commit comments

Comments
 (0)