Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

♻️ Migrate og image api routes to app dir (#1586)

Luke Vella83e3d85c97b9
diff --git a/apps/landing/src/pages/api/og-image.tsx b/apps/landing/src/app/api/og-image/route.tsx
similarity index 93%
rename from apps/landing/src/pages/api/og-image.tsx
rename to apps/landing/src/app/api/og-image/route.tsx
index a94049a9c..9a5e51ee8 100644
--- a/apps/landing/src/pages/api/og-image.tsx
+++ b/apps/landing/src/app/api/og-image/route.tsx
@@ -2,9 +2,7 @@
import { ImageResponse } from "next/og";
import type { NextRequest } from "next/server";
-export const config = {
- runtime: "edge",
-};
+export const runtime = "edge";
const regularFont = fetch(
new URL("/public/static/fonts/inter-regular.ttf", import.meta.url),
@@ -14,13 +12,13 @@ const boldFont = fetch(
new URL("/public/static/fonts/inter-bold.ttf", import.meta.url),
).then((res) => res.arrayBuffer());
-export default async function handler(req: NextRequest) {
+export async function GET(req: NextRequest) {
const [regularFontData, boldFontData] = await Promise.all([
regularFont,
boldFont,
]);
- const { searchParams } = req.nextUrl;
+ const { searchParams } = new URL(req.url);
const title = searchParams.get("title");
const excerpt = searchParams.get("excerpt");
diff --git a/apps/web/src/pages/api/og-image-poll.tsx b/apps/web/src/app/api/og-image-poll/route.tsx
similarity index 94%
rename from apps/web/src/pages/api/og-image-poll.tsx
rename to apps/web/src/app/api/og-image-poll/route.tsx
index 64c9cea88..fdd66fda8 100644
--- a/apps/web/src/pages/api/og-image-poll.tsx
+++ b/apps/web/src/app/api/og-image-poll/route.tsx
@@ -8,9 +8,7 @@ const schema = z.object({
author: z.string().min(1),
});
-export const config = {
- runtime: "edge",
-};
+export const runtime = "edge";
const regularFont = fetch(
new URL("/public/static/fonts/inter-regular.ttf", import.meta.url),
@@ -20,12 +18,13 @@ const boldFont = fetch(
new URL("/public/static/fonts/inter-bold.ttf", import.meta.url),
).then((res) => res.arrayBuffer());
-export default async function handler(req: NextRequest) {
+export async function GET(req: NextRequest) {
const [regularFontData, boldFontData] = await Promise.all([
regularFont,
boldFont,
]);
- const { searchParams } = req.nextUrl;
+
+ const { searchParams } = new URL(req.url);
const { title, author } = schema.parse({
title: searchParams.get("title"),