I have several websites, mostly clones, all of them using the same API Key. I'm hitting rate limits, and I don't really know why. I though that this could be the reason.
Would making new API keys reduce the rate limit errors for each website?
Summary
User is experiencing rate limit errors while using the Appwrite API. They are using the node-appwrite and appwrite packages for the backend and frontend respectively. The issue occurs when making requests on behalf of the user. The user is using Next.js with TypeScript. They have received suggestions to upgrade their Appwrite version and to backup their files before doing so. The user is also considering creating new API keys for each website to potentially reduce the rate limit errors.
Solution:
- Upgrade Appwrite to version 1.3.2 and run the necessary migrations.
- Backup all files, including docker-compose.yml, .env, database,
What endpoint you're trying to reach, As I remember that at least one also had rate limits even for API.
bazoo
Rank 1: Thread
Apr 27, 2023, 21:27
/account endpoints.
Binyamin
Apr 27, 2023, 21:42
What is the full error you're getting?
Binyamin
Apr 27, 2023, 21:43
Shouldn't be
bazoo
Rank 1: Thread
Apr 28, 2023, 08:36
here are some of them (from docker logs)
[Error] Timestamp: 2023-04-28T06:49:17+00:00
[Error] Method: POST
[Error] URL: /v1/account/sessions/anonymous
[Error] Type: Appwrite\Extend\Exception
[Error] Message: Rate limit for the current endpoint has been exceeded. Please try again after some time.
[Error] File: /usr/src/code/app/controllers/shared/api.php
[Error] Line: 127
[Error] Timestamp: 2023-04-28T08:33:49+00:00
[Error] Method: POST
[Error] URL: /v1/account/recovery
[Error] Type: Appwrite\Extend\Exception
[Error] Message: Rate limit for the current endpoint has been exceeded. Please try again after some time.
[Error] File: /usr/src/code/app/controllers/shared/api.php
[Error] Line: 127
Here's the JSON response from the second error above:
{
"message":"Rate limit for the current endpoint has been exceeded. Please try again after some time.",
"code":429,
"type":"general_rate_limit_exceeded",
"version":"1.0.2"
}
bazoo
Rank 1: Thread
Apr 28, 2023, 08:37
sorry for not replying earlier, i made the post right before going to bed
Binyamin
Apr 28, 2023, 11:41
What version of Appwrite you're using?
bazoo
Rank 1: Thread
Apr 28, 2023, 14:53
1.0.2
Binyamin
Apr 28, 2023, 14:58
Maybe in this version setting the user as App (API) user dos not work with API keys. so first what I would do
Backup everything. yml, .env, database and volumes.
Upgrading to 1.1.0 and run migration
Upgrading to 1.2.0 and run migration
Upgrading to 1.3.2 and run migration
Notice that the upgrade should be from one minor to minor
// Server side only code
export const appwrite = new Client()
.setKey(process.env.APPWRITE_API_KEY!)
.setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID!)
.setEndpoint(ENDPOINT);
// When I need to do something in the backend on behalf of the user
function getAppwriteClient(jwt: string): Client {
return new Client()
.setKey(process.env.APPWRITE_API_KEY!)
.setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID!)
.setEndpoint(ENDPOINT)
.setJWT(jwt);
}
Using Nextjs with TypeScript
Drake
Admin
Apr 28, 2023, 22:37
Ah i see. Kk. In this case, those requests on behalf of the user are subject to rate limits