Closed jameswong3388 closed 1 year ago
this is a browser console, right?
I suspect your environment variables are not available in your browser, can you double check?
pretty sure this is what's happening here
@chronark Found the solution?
I posted it above the url is not loaded properly from your environment
@chronark, but i am able to log the client
export const checkCompletionsRateLimits = async (identifier: User) => {
const redis = getRedisClient()
console.log('redis', redis)
const ratelimit = new Ratelimit({
redis: redis,
limiter: Ratelimit.cachedFixedWindow(1, '86400 s'),
analytics: true,
timeout: 1000,
})
console.log('ratelimit', ratelimit)
const result = await ratelimit.limit(rateLimitTypeToKey(identifier))
console.log('result', result)
// Calcualte the remaining time until generations are reset
const diff = Math.abs(new Date(result.reset).getTime() - new Date().getTime())
const hours = Math.floor(diff / 1000 / 60 / 60)
const minutes = Math.floor(diff / 1000 / 60) - hours * 60
return { result, hours, minutes }
}
logging the client doesn't proof anything try logging the url or token
@chronark, oh yea it say undefined, but my other libraries were able to access the env var in .env.local
you are running this in your browser, not server side by default environment variables are not leaked to the browser
I cant receive JSON from the response, but rather HTML.
.env
redis.ts
rate-limit.ts
As you can see from the above file, I am able to log
ratelimit
, but not theresult
, i really need help !