diff --git a/src/app/rss.xml/route.ts b/src/app/rss.xml/route.ts index 979a4fc..75e80a8 100644 --- a/src/app/rss.xml/route.ts +++ b/src/app/rss.xml/route.ts @@ -19,11 +19,16 @@ function escapeXml(value: string): string { } export async function GET() { - const supabase = await createClient(); - const { items } = await fetchNewsList(supabase, { - page: 1, - pageSize: 30, - }).catch(() => ({ items: [], total: 0, page: 1, pageSize: 30 })); + let items: Awaited>['items'] = []; + try { + const supabase = await createClient(); + ({ items } = await fetchNewsList(supabase, { + page: 1, + pageSize: 30, + }).catch(() => ({ items: [], total: 0, page: 1, pageSize: 30 }))); + } catch { + items = []; + } const rssItems = items .map((article) => { diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts index fb3897e..243356f 100644 --- a/src/app/sitemap.ts +++ b/src/app/sitemap.ts @@ -12,18 +12,6 @@ import { absoluteUrl } from '@/lib/url'; export const revalidate = 86400; export default async function sitemap(): Promise { - const supabase = await createClient(); - - const [news, reviews] = await Promise.all([ - fetchNewsList(supabase, { page: 1, pageSize: 200 }).catch(() => ({ - items: [], - total: 0, - page: 1, - pageSize: 200, - })), - fetchMonthlyReviews(supabase).catch(() => []), - ]); - const staticEntries: MetadataRoute.Sitemap = [ { url: siteConfig.url, lastModified: new Date(), priority: 1 }, { url: absoluteUrl('/news'), lastModified: new Date(), priority: 0.9 }, @@ -35,6 +23,23 @@ export default async function sitemap(): Promise { { url: absoluteUrl('/authors'), lastModified: new Date(), priority: 0.5 }, ]; + let supabase; + try { + supabase = await createClient(); + } catch { + return staticEntries; + } + + const [news, reviews] = await Promise.all([ + fetchNewsList(supabase, { page: 1, pageSize: 200 }).catch(() => ({ + items: [], + total: 0, + page: 1, + pageSize: 200, + })), + fetchMonthlyReviews(supabase).catch(() => []), + ]); + const newsEntries: MetadataRoute.Sitemap = news.items.map((article) => ({ url: absoluteUrl(`/news/${article.slug}`), lastModified: new Date(article.updatedAt ?? article.publishedAt), diff --git a/src/middleware.ts b/src/proxy.ts similarity index 88% rename from src/middleware.ts rename to src/proxy.ts index a0f7c2f..8dd2bfb 100644 --- a/src/middleware.ts +++ b/src/proxy.ts @@ -1,7 +1,7 @@ import type { NextRequest } from 'next/server'; import { updateSession } from '@/lib/supabase/middleware'; -export async function middleware(request: NextRequest) { +export async function proxy(request: NextRequest) { return updateSession(request); }