Skip to content

Full Toolkit for Next-Level Domain Analysis

Remove search suggestions (for now) 👀

Felix Wotschofsky56e211872ff1
diff --git a/app/_components/search-form.tsx b/app/_components/search-form.tsx
index 0e2e923..9878f09 100644
--- a/app/_components/search-form.tsx
+++ b/app/_components/search-form.tsx
@@ -1,6 +1,5 @@
'use client';
-import { useDebounce } from '@uidotdev/usehooks';
import { Loader2Icon, SearchIcon } from 'lucide-react';
import { usePlausible } from 'next-plausible';
import { usePathname, useRouter } from 'next/navigation';
@@ -16,7 +15,6 @@ import {
useState,
} from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
-import useSWR from 'swr';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -38,17 +36,8 @@ const normalizeDomain = (input: string) => {
};
const useSuggestions = (domain: string) => {
- const debouncedDomain = useDebounce(domain, 200);
-
- const { data: suggestions } = useSWR<string[]>(
- domain
- ? `/api/search-suggestions?q=${encodeURIComponent(debouncedDomain.toLowerCase())}`
- : null,
- { keepPreviousData: true }
- );
-
return {
- suggestions: domain ? suggestions : EXAMPLE_DOMAINS,
+ suggestions: domain ? [] : EXAMPLE_DOMAINS,
};
};
diff --git a/app/api/search-suggestions/route.ts b/app/api/search-suggestions/route.ts
deleted file mode 100644
index 8ec4cdd..0000000
--- a/app/api/search-suggestions/route.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { NextResponse } from 'next/server';
-
-import { applyRateLimit } from '@/lib/api';
-import { getSearchSuggestions } from '@/lib/search';
-
-export const runtime = 'edge';
-export const preferredRegion = 'home';
-
-export const GET = async (request: Request) => {
- const { searchParams } = new URL(request.url);
- const query = searchParams.get('q');
-
- if (!query) {
- return new Response('Missing query', {
- status: 400,
- });
- }
-
- if (query.includes('%')) {
- return new Response('Invalid query', {
- status: 400,
- });
- }
-
- const visitorIp = request.headers.get('x-forwarded-for') ?? '';
- const identifier = ['search-suggestions', visitorIp].join(':');
- const isAllowed = await applyRateLimit(identifier, 15, '60s');
- if (!isAllowed) {
- return new Response('Too many requests', {
- status: 429,
- });
- }
-
- const suggestions = await getSearchSuggestions(query);
-
- return NextResponse.json(suggestions, {
- headers: {
- 'Cache-Control': 'public, s-maxage=600',
- },
- });
-};