Authentication and authorization
This app demonstrates @unkey/ratelimit and how you can rate limit your astro routes. Try the following curl request. The route is rate-limited for 3 requests per 30 seconds .
Create an account with Unkey
Go to unkey ratelimits
Create a new namespace with the name astro
Go to settings/root-keys and create a root key with Ratelimit permissions
You can follow this link to create the root key with ratelimit permissions https://app.unkey.com/settings/root-keys/new?permissions=ratelimit..create_namespace,ratelimit..read_namespace,ratelimit..limit,ratelimit..update_namespace,ratelimit.*.delete_namespace
Add it in the .env file UNKEY_ROOT_KEY
Clone the repository:
1git clone https://github.com/harshsbhat/unkey-astro.git2cd unkey-astro
Install the dependencies
1pnpm install
Start the project. It should start on port 4321
1pnpm dev
Try making requests to the ratelimited route. It should only allow 3 requests per 30 seconds:
1curl http://localhost:4321/api/ratelimited
2500 verifications and 100K successful rate‑limited requests per month. No CC required.