diff --git a/app/recents/image/route.tsx b/app/recents/image/route.tsx index c9f9eb28..1a15e8b7 100644 --- a/app/recents/image/route.tsx +++ b/app/recents/image/route.tsx @@ -23,7 +23,7 @@ export async function GET() { ? getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_PER_CATEGORY, recent: true, - }) + }).catch(() => []) : [], getIBMPlexMono(), getImageResponseCacheControlHeaders(), diff --git a/app/recents/page.tsx b/app/recents/page.tsx index ef169046..d60c581e 100644 --- a/app/recents/page.tsx +++ b/app/recents/page.tsx @@ -1,4 +1,4 @@ -import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo'; +import { INFINITE_SCROLL_GRID_INITIAL, Photo } from '@/photo'; import { generateMetaForRecents } from '@/recents/meta'; import RecentsOverview from '@/recents/RecentsOverview'; import { getPhotosRecentsDataCached } from '@/recents/data'; @@ -9,7 +9,9 @@ import { redirect } from 'next/navigation'; import { getAppText } from '@/i18n/state/server'; const getPhotosRecentsDataCachedCached = cache(() => - getPhotosRecentsDataCached({ limit: INFINITE_SCROLL_GRID_INITIAL })); + getPhotosRecentsDataCached({ limit: INFINITE_SCROLL_GRID_INITIAL }) + .catch(() => [[] as Photo[], { count: 0, dateRange: undefined}] as const), +); export async function generateMetadata(): Promise { const [ diff --git a/src/platforms/postgres.ts b/src/platforms/postgres.ts index 056b3400..27c2c85a 100644 --- a/src/platforms/postgres.ts +++ b/src/platforms/postgres.ts @@ -3,7 +3,12 @@ import { removeParamsFromUrl } from '@/utility/url'; import { Pool, QueryResult, QueryResultRow } from 'pg'; const pool = new Pool({ - connectionString: removeParamsFromUrl(process.env.POSTGRES_URL, ['sslmode']), + ...process.env.POSTGRES_URL && { + connectionString: removeParamsFromUrl( + process.env.POSTGRES_URL, + ['sslmode'], + ), + }, ...POSTGRES_SSL_ENABLED && { ssl: true }, }); diff --git a/src/utility/url.ts b/src/utility/url.ts index 0f83e113..63c927ce 100644 --- a/src/utility/url.ts +++ b/src/utility/url.ts @@ -18,7 +18,7 @@ export const makeUrlAbsolute = (url?: string) => url !== undefined .replace(/\/$/, '') : undefined; -export const removeParamsFromUrl = (urlString = '', params: string[]) => { +export const removeParamsFromUrl = (urlString: string, params: string[]) => { const url = new URL(urlString); for (const param of params) { url.searchParams.delete(param);