shadcn-ui / taxonomy

An open source application built using the new router, server components and everything new in Next.js 13.
https://tx.shadcn.com
MIT License
18.57k stars 2.57k forks source link

Type error: Route "app/api/og/route.tsx" has an invalid export #239

Open pwnllc opened 1 year ago

pwnllc commented 1 year ago

Hello! When I try to build this on my RPi, the following error occurs:

app/api/og/route.tsx
Type error: Route "app/api/og/route.tsx" has an invalid export:
  "Promise<ImageResponse>" is not a valid GET return type:
    Expected "void | Response | Promise<void | Response>", got "Promise<ImageResponse>".
      Expected "Promise<void | Response>", got "Promise<ImageResponse>".
        Expected "void | Response", got "ImageResponse".
SaadBazaz commented 11 months ago

Same problem here. Any solution so far?

fardeenes7 commented 11 months ago

I have solved this by moving the og API from app/api/og/route.ts to pages/api/og.ts. This seemed the easiest and most stable solution to me

elickeenanjones commented 9 months ago

Is there any other solutions so far?

jiaweing commented 9 months ago

I have solved this by moving the og API from app/api/og/route.ts to pages/api/og.ts. This seemed the easiest and most stable solution to me

This worked for me after cracking my head around for days. There isn't any solution around on why Next 14 does not support ImageResponse as a response in an api route under the app router.

jiaweing commented 9 months ago

I also tried the opengraph-image.tsx method but there isn't any way to pass in any parameters other than only using those from the url. https://nextjs.org/docs/app/building-your-application/optimizing/metadata#dynamic-image-generation

tknickman commented 7 months ago

Change the import to: import { ImageResponse } from "next/og"