diff --git a/.env.example b/.env.example index e979aac..c556dbc 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -ANIWATCH_API = your animwatch-api key \ No newline at end of file +# Your AniWatch API URL - replace with your own API endpoint +ANIWATCH_API=https://your-api-url.com \ No newline at end of file diff --git a/next.config.js b/next.config.js index 54b5db7..539b60d 100644 --- a/next.config.js +++ b/next.config.js @@ -34,14 +34,19 @@ const nextConfig = { }, serverExternalPackages: ['puppeteer-core'], async rewrites() { + // Get the API URL from environment variable or use default + const apiUrl = process.env.ANIWATCH_API; + // Extract the base URL without the /api/v2/hianime path + const baseUrl = apiUrl.replace('/api/v2/hianime', ''); + return [ { source: '/api/v2/hianime/:path*', - destination: 'https://justaniwatchapi.vercel.app/api/v2/hianime/:path*' + destination: `${apiUrl}/:path*` }, { source: '/api/anime/:path*', - destination: 'https://justaniwatchapi.vercel.app/api/v2/hianime/anime/:path*' + destination: `${apiUrl}/anime/:path*` } ] }, diff --git a/src/app/page.jsx b/src/app/page.jsx index 91ecefd..5cffa8d 100644 --- a/src/app/page.jsx +++ b/src/app/page.jsx @@ -30,6 +30,7 @@ export default function LandingPage() { if (searchQuery.trim().length > 2) { try { const suggestions = await fetchSearchSuggestions(searchQuery); + // Update to use the same format as home page search setSearchSuggestions(suggestions || []); setShowSuggestions(true); } catch (error) { @@ -70,14 +71,16 @@ export default function LandingPage() { const handleSearch = (e) => { e.preventDefault(); if (searchQuery.trim()) { - router.push(`/search/${searchQuery}`); + router.push(`/search?q=${encodeURIComponent(searchQuery)}`); setSearchQuery(''); setShowSuggestions(false); } }; - const handleSuggestionClick = (title) => { - router.push(`/search/${title}`); + const handleSuggestionClick = (suggestion) => { + // Updated to handle object-based suggestions + const query = suggestion.title || suggestion; + router.push(`/search?q=${encodeURIComponent(query)}`); setSearchQuery(''); setShowSuggestions(false); }; @@ -184,10 +187,32 @@ export default function LandingPage() { {searchSuggestions.map((suggestion, index) => (
{suggestion.title || suggestion}
+ {suggestion.jname && ( +{suggestion.jname}
+ )} +JustAnime offers the best user experience for anime streaming with fast loading speeds, a beautiful interface, no intrusive ads, large content library, HD quality, and weekly updates. Our clean design and extensive features set us apart from other platforms.