This is a Next.js application that enables users to explore domain registration details using WHOIS and RDAP protocols. It features a clean, intuitive UI and includes server-side API route rate limiting to prevent abuse.
Follow these steps to set up and run the project on your local machine.
If you created a new Next.js project based on prior instructions, you can skip this step. Otherwise:
git clone https://github.com/CasualEngineerZombie/whois-rdap-explorer
cd whois-rdap-explorerInstall all required npm packages:
npm install
# or
yarn installThis application uses Vercel KV for persistent and scalable rate limiting.
- Create a Vercel Account: Sign up at vercel.com if you don't have an account.
- Create a KV Database:
- Navigate to the "Storage" tab in your Vercel Dashboard.
- Click "Connect Store" and select "KV". Follow the prompts to create a new KV database and link it to your Next.js project.
- Get Environment Variables: Vercel will provide connection details (URL and Token) after creation.
- Create .env.local: In the project root, create a
.env.localfile and add the following environment variables (replace<your_values>with the actual values from Vercel KV):
KV_URL="<your_kv_url>"
KV_REST_API_TOKEN="<your_kv_token>"
KV_REST_API_URL="<your_kv_rest_api_url>"Important: These variables are required for local development. Invalid or missing variables will cause the rate limiter to fail.
Ensure your project structure aligns with the following to ensure components resolve correctly:
whois-rdap-explorer/
├── src/
│ ├── app/
│ │ ├── actions/
│ │ │ └── whois-rdap.ts
│ │ ├── api/
│ │ │ └── whois-rdap/
│ │ │ └── route.ts
│ │ ├── components/
│ │ │ └── WHOISRDAPExplorer.tsx
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── lib/
│ │ └── ratelimit.ts
│ └── types/
│ └── whois-rdap.d.ts
├── .env.local
├── next.config.mjs
├── package.json
├── tsconfig.json
└── README.md
After completing the setup, run the application in development mode:
npm run dev
# or
yarn devThe application will be available at http://localhost:3000.
To test the API route rate limiting (configured in lib/ratelimit.ts for 5 requests per 10 seconds per IP):
-
Ensure the development server is running.
-
Use a terminal or a tool like Postman/Insomnia.
-
Send POST requests rapidly to
http://localhost:3000/api/whois-rdapwith a JSON body like{"domain": "example.com"}.curl -X POST -H "Content-Type: application/json" -d '{"domain": "example.com"}' http://localhost:3000/api/whois-rdap
-
Observe the responses:
- The first 5 requests within a 10-second window should return
200 OKwith WHOIS/RDAP data. - The 6th request (and subsequent ones within the window) should return
429 Too Many Requestswith an error message indicating the rate limit. - The
429response headers will includeX-RateLimit-Limit,X-RateLimit-Remaining, andX-RateLimit-Reset(Unix timestamp).
- The first 5 requests within a 10-second window should return
-
Wait for the reset: After a
429response, wait for theRetry-Afterduration (or more than 10 seconds from the first request). Subsequent requests should succeed again.