diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts index 74197d24..fae49073 100644 --- a/src/app/api/auth/[...nextauth]/route.ts +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -1,2 +1 @@ export { GET, POST } from '@/auth'; -export const runtime = 'edge'; diff --git a/src/app/api/route.ts b/src/app/api/route.ts index 6c367600..19484bd4 100644 --- a/src/app/api/route.ts +++ b/src/app/api/route.ts @@ -6,8 +6,6 @@ import { SITE_TITLE, } from '@/site/config'; -export const runtime = 'edge'; - export async function GET() { if (PUBLIC_API_ENABLED) { const photos = await getPhotosCached({ limit: API_PHOTO_REQUEST_LIMIT }); diff --git a/src/app/api/storage/presigned-url/[key]/route.ts b/src/app/api/storage/presigned-url/[key]/route.ts index da506a22..7d01b2af 100644 --- a/src/app/api/storage/presigned-url/[key]/route.ts +++ b/src/app/api/storage/presigned-url/[key]/route.ts @@ -10,8 +10,6 @@ import { import { CURRENT_STORAGE } from '@/site/config'; import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; -export const runtime = 'edge'; - export async function GET( _: Request, { params: { key } }: { params: { key: string } }, diff --git a/src/app/film/[simulation]/image/route.tsx b/src/app/film/[simulation]/image/route.tsx index 7146f9b6..58e5c8ef 100644 --- a/src/app/film/[simulation]/image/route.tsx +++ b/src/app/film/[simulation]/image/route.tsx @@ -10,8 +10,6 @@ import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; -export const runtime = 'edge'; - export async function GET( _: Request, context: { params: { simulation: FilmSimulation } }, diff --git a/src/app/home-image/route.tsx b/src/app/home-image/route.tsx index 55eb29aa..37d0b5a0 100644 --- a/src/app/home-image/route.tsx +++ b/src/app/home-image/route.tsx @@ -8,8 +8,6 @@ import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; -export const runtime = 'edge'; - export async function GET() { const [ photos, diff --git a/src/app/p/[photoId]/image/route.tsx b/src/app/p/[photoId]/image/route.tsx index 657016d7..965db7df 100644 --- a/src/app/p/[photoId]/image/route.tsx +++ b/src/app/p/[photoId]/image/route.tsx @@ -5,8 +5,6 @@ import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; -export const runtime = 'edge'; - export async function GET( _: Request, context: { params: { photoId: string } }, diff --git a/src/app/shot-on/[make]/[model]/image/route.tsx b/src/app/shot-on/[make]/[model]/image/route.tsx index cebecea5..7fc54ac4 100644 --- a/src/app/shot-on/[make]/[model]/image/route.tsx +++ b/src/app/shot-on/[make]/[model]/image/route.tsx @@ -9,8 +9,6 @@ import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; -export const runtime = 'edge'; - export async function GET( _: Request, context: CameraProps, diff --git a/src/app/tag/[tag]/image/route.tsx b/src/app/tag/[tag]/image/route.tsx index 710842c0..fbe0b282 100644 --- a/src/app/tag/[tag]/image/route.tsx +++ b/src/app/tag/[tag]/image/route.tsx @@ -8,8 +8,6 @@ import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; -export const runtime = 'edge'; - export async function GET( _: Request, context: { params: { tag: string } }, diff --git a/src/app/template-image-tight/route.tsx b/src/app/template-image-tight/route.tsx index cee5b868..944e9291 100644 --- a/src/app/template-image-tight/route.tsx +++ b/src/app/template-image-tight/route.tsx @@ -9,8 +9,6 @@ import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; -export const runtime = 'edge'; - export async function GET() { const [ photos, diff --git a/src/app/template-image/route.tsx b/src/app/template-image/route.tsx index c7e6f1ca..37d2603b 100644 --- a/src/app/template-image/route.tsx +++ b/src/app/template-image/route.tsx @@ -9,8 +9,6 @@ import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; -export const runtime = 'edge'; - export async function GET() { const [ photos, diff --git a/src/site/font.ts b/src/site/font.ts index 6fb91a8e..e01131bc 100644 --- a/src/site/font.ts +++ b/src/site/font.ts @@ -1,10 +1,26 @@ +import fs from 'fs'; +import path from 'path'; +import { cwd } from 'process'; + const FONT_FAMILY_IBM_PLEX_MONO = 'IBMPlexMono'; -export const getIBMPlexMonoMedium = () => fetch(new URL( - '/public/fonts/IBMPlexMono-Medium.ttf', - import.meta.url -)) - .then(res => res.arrayBuffer()) +const getFontData = async () => { + let data: ArrayBuffer; + if (typeof fs !== 'undefined') { + data = fs.readFileSync(path.join( + cwd(), + '/public/fonts/IBMPlexMono-Medium.ttf', + )); + } else { + data = await fetch(new URL( + '/public/fonts/IBMPlexMono-Medium.ttf', + import.meta.url + )).then(res => res.arrayBuffer()); + } + return data; +}; + +export const getIBMPlexMonoMedium = () => getFontData() .then(data => ({ fontFamily: FONT_FAMILY_IBM_PLEX_MONO, fonts: [{