Skip to content

Commit

Permalink
fix(og images): use edge runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Jan 28, 2025
1 parent de251c6 commit dc09c98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/pages/api/linkpreview/[timestamp]/[guild]/[group].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import loadGoogleFont from "fonts/loadGoogleFont"
import { ImageResponse } from "next/og"
import { Guild } from "types"

export const config = {
runtime: "edge",
}

const interFont = loadGoogleFont("Inter", "400")
const interBoldFont = loadGoogleFont("Inter", "700")
const dystopianFont = fetch(
Expand All @@ -19,7 +23,7 @@ const handler = async (req, _) => {
?.split("/")
?.filter((param) => !!param) ?? []

if (!urlName || !groupUrlName) return new ImageResponse(<></>, { status: 404 })
if (!urlName || !groupUrlName) return new Response(undefined, { status: 404 })

const [guild, groups, guildRoles]: [Guild, Guild["groups"], Guild["roles"]] =
await Promise.all([
Expand Down
6 changes: 5 additions & 1 deletion src/pages/api/linkpreview/[timestamp]/[guild]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import loadGoogleFont from "fonts/loadGoogleFont"
import { ImageResponse } from "next/og"
import { Guild } from "types"

export const config = {
runtime: "edge",
}

const interFont = loadGoogleFont("Inter", "400")
const interBoldFont = loadGoogleFont("Inter", "700")
const dystopianFont = fetch(
Expand All @@ -19,7 +23,7 @@ const handler = async (req, _) => {
?.split("/")
?.filter((param) => !!param) ?? []

if (!urlName) return new ImageResponse(<></>, { status: 404 })
if (!urlName) return new Response(undefined, { status: 404 })

const [guild, guildRoles]: [Guild, Guild["roles"]] = await Promise.all([
fetch(`${env.NEXT_PUBLIC_API.replace("v1", "v2")}/guilds/${urlName}`).then(
Expand Down

0 comments on commit dc09c98

Please sign in to comment.